Skip to content

feat(github): add workflow_dispatch to the GitHub notification service#459

Open
yugstar wants to merge 1 commit into
argoproj:masterfrom
yugstar:feat-442-workflow-dispatch
Open

feat(github): add workflow_dispatch to the GitHub notification service#459
yugstar wants to merge 1 commit into
argoproj:masterfrom
yugstar:feat-442-workflow-dispatch

Conversation

@yugstar

@yugstar yugstar commented Jun 20, 2026

Copy link
Copy Markdown

Closes #442

What

Adds a workflowDispatch option to the GitHub notification service so a notification can trigger a GitHub Actions workflow dispatch event.

The service already supported repository_dispatch (#393); workflow_dispatch was the remaining half of #442.

Usage

template.app-deployed: |
  github:
    workflowDispatch:
      workflow: deploy.yml
      ref: "{{.app.spec.source.targetRevision}}"
      inputs: |
        {
          "application": "{{.app.metadata.name}}",
          "revision": "{{.app.status.operationState.syncResult.revision}}"
        }
  • workflow — the workflow file name (e.g. deploy.yml) or its ID.
  • ref — the branch or tag the workflow runs from.
  • inputs — optional JSON object of workflow inputs (templated, then decoded into the inputs map).

The GitHub App / token needs the actions: write permission.

Implementation

Mirrors the existing repositoryDispatch design end to end:

  • New GitHubWorkflowDispatch struct + workflowDispatch field on GitHubNotification.
  • Templater parses/executes workflow, ref, and inputs (the inputs JSON string is templated then json.Unmarshal-ed into the inputs map, just like repositoryDispatch.clientPayload).
  • New actionsService interface + GetActions() on the githubClient interface and adapter, calling Actions.CreateWorkflowDispatchEventByFileName (go-github v69).
  • Docs section + example.

Tests

  • TestGetTemplater_Github_WorkflowDispatch — verifies workflow, ref, and inputs template correctly.
  • TestGitHubService_Send_WorkflowDispatch — verifies the dispatch is sent with the right workflow file, ref, and decoded inputs map.

go build, go vet, gofmt, and the full pkg/services test suite pass.

The GitHub notification service supported repository_dispatch but not
workflow_dispatch. Add a workflowDispatch option that triggers a workflow
dispatch event for a given workflow file and ref, with optional templated
inputs, mirroring the existing repositoryDispatch implementation.

Closes argoproj#442

Signed-off-by: Aman Raj <aman.yug@gmail.com>
@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.13%. Comparing base (da04400) to head (f4bf039).
⚠️ Report is 37 commits behind head on master.

Files with missing lines Patch % Lines
pkg/services/github.go 57.14% 10 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #459      +/-   ##
==========================================
+ Coverage   55.41%   57.13%   +1.72%     
==========================================
  Files          46       49       +3     
  Lines        4125     3824     -301     
==========================================
- Hits         2286     2185     -101     
+ Misses       1511     1273     -238     
- Partials      328      366      +38     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yugstar

yugstar commented Jun 22, 2026

Copy link
Copy Markdown
Author

For context on why this is worth having alongside the existing repository_dispatch support (#393): the two cover different needs.

  • repository_dispatch sends a custom event type + payload that a workflow must subscribe to via on: repository_dispatch and then parse.
  • workflow_dispatch runs a specific workflow file directly on a chosen ref, with typed inputs — the same as the "Run workflow" button in the UI. No custom event wiring needed.

The original issue (#442) asked for both, and this completes the second half. The implementation mirrors repository_dispatch exactly (struct + templater + a new actionsService on the client interface + Send), with tests and docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add workflow_dispatch and repository_dispatch to github notification service

1 participant