workflow_run

This page was generated based on Github’s Documentation. See our welcome page for context and details.

Github Event workflow_run #

Github Action Trigger #

source

Webhook event payloadActivity typesGITHUB_SHAGITHUB_REF
workflow_runcompleted
requested
in_progress
Last commit on default branchDefault branch

Note: More than one activity type triggers this event. The requested activity type does not occur when a workflow is re-run. For information about each activity type, see “Webhook events and payloads.” By default, all activity types trigger workflows that run on this event. You can limit your workflow runs to specific activity types using the types keyword. For more information, see “Workflow syntax for GitHub Actions.”

Note: This event will only trigger a workflow run if the workflow file is on the default branch.

Note: You can’t use workflow_run to chain together more than three levels of workflows. For example, if you attempt to trigger five workflows (named B to F) to run sequentially after an initial workflow A has run (that is: A → B → C → D → E → F), workflows E and F will not be run.

This event occurs when a workflow run is requested or completed. It allows you to execute a workflow based on execution or completion of another workflow. The workflow started by the workflow_run event is able to access secrets and write tokens, even if the previous workflow was not. This is useful in cases where the previous workflow is intentionally not privileged, but you need to take a privileged action in a later workflow.

In this example, a workflow is configured to run after the separate “Run Tests” workflow completes.

on:
  workflow_run:
    workflows: [Run Tests]
    types:
      - completed

If you specify multiple workflows for the workflow_run event, only one of the workflows needs to run. For example, a workflow with the following trigger will run whenever the “Staging” workflow or the “Lab” workflow completes.

on:
  workflow_run:
    workflows: [Staging, Lab]
    types:
      - completed

Running a workflow based on the conclusion of another workflow #

A workflow run is triggered regardless of the conclusion of the previous workflow. If you want to run a job or step based on the result of the triggering workflow, you can use a conditional with the github.event.workflow_run.conclusion property. For example, this workflow will run whenever a workflow named “Build” completes, but the on-success job will only run if the “Build” workflow succeeded, and the on-failure job will only run if the “Build” workflow failed:

on:
  workflow_run:
    workflows: [Build]
    types: [completed]

jobs:
  on-success:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    steps:
      - run: echo 'The triggering workflow passed'
  on-failure:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'failure' }}
    steps:
      - run: echo 'The triggering workflow failed'

Limiting your workflow to run based on branches #

You can use the branches or branches-ignore filter to specify what branches the triggering workflow must run on in order to trigger your workflow. For more information, see “Workflow syntax for GitHub Actions.” For example, a workflow with the following trigger will only run when the workflow named Build runs on a branch named canary.

on:
  workflow_run:
    workflows: [Build]
    types: [requested]
    branches: [canary]

Using data from the triggering workflow #

You can access the workflow_run event payload that corresponds to the workflow that triggered your workflow. For example, if your triggering workflow generates artifacts, a workflow triggered with the workflow_run event can access these artifacts.

The following workflow uploads data as an artifact. (In this simplified example, the data is the pull request number.)

name: Upload data

on:
  pull_request:

jobs:
  upload:
    runs-on: ubuntu-latest

    steps:
      - name: Save PR number
        env:
          PR_NUMBER: ${{ github.event.number }}
        run: |
          mkdir -p ./pr
          echo $PR_NUMBER > ./pr/pr_number          
      - uses: actions/upload-artifact@v4
        with:
          name: pr_number
          path: pr/

When a run of the above workflow completes, it triggers a run of the following workflow. The following workflow uses the github.event.workflow_run context and the GitHub REST API to download the artifact that was uploaded by the above workflow, unzips the downloaded artifact, and comments on the pull request whose number was uploaded as an artifact.

name: Use the data

on:
  workflow_run:
    workflows: [Upload data]
    types:
      - completed

jobs:
  download:
    runs-on: ubuntu-latest
    steps:
      - name: 'Download artifact'
        uses: actions/github-script@v6
        with:
          script: |
            let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
               owner: context.repo.owner,
               repo: context.repo.repo,
               run_id: context.payload.workflow_run.id,
            });
            let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
              return artifact.name == "pr_number"
            })[0];
            let download = await github.rest.actions.downloadArtifact({
               owner: context.repo.owner,
               repo: context.repo.repo,
               artifact_id: matchArtifact.id,
               archive_format: 'zip',
            });
            let fs = require('fs');
            fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));            

      - name: 'Unzip artifact'
        run: unzip pr_number.zip

      - name: 'Comment on PR'
        uses: actions/github-script@v6
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            let fs = require('fs');
            let issue_number = Number(fs.readFileSync('./pr_number'));
            await github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: issue_number,
              body: 'Thank you for the PR!'
            });            

Press alt+up to activate

Event Payload #

source

Activities: completed, in_progress, requested

Common Fields #

These fields are common to every event types available with this trigger.
fieldtyperequireddescription
github.event.enterpriseobjectoptional

An enterprise on GitHub. Webhook payloads contain the enterprise property when the webhook is configured on an enterprise account or an organization that’s part of an enterprise account. For more information, see “About enterprise accounts."

github.event.installationobjectoptional

The GitHub App installation. Webhook payloads contain the installation property when the event is configured for and sent to a GitHub App. For more information, see “Using webhooks with GitHub Apps."

github.event.organizationobjectoptional

A GitHub organization. Webhook payloads contain the organization property when the webhook is configured for an organization, or when the event occurs from activity in a repository owned by an organization.

github.event.repositoryobjectrequired

The repository on GitHub where the event occurred. Webhook payloads contain the repository property when the event occurs from activity in a repository.

github.event.senderobjectrequired

The GitHub user that triggered the event. This property is included in every webhook payload.

github.event.workflowobject or nullrequired
github.event.workflow.badge_urlstringrequired
github.event.workflow.created_atstringrequired
github.event.workflow.html_urlstringrequired
github.event.workflow.idintegerrequired
github.event.workflow.namestringrequired
github.event.workflow.node_idstringrequired
github.event.workflow.pathstringrequired
github.event.workflow.statestringrequired
github.event.workflow.updated_atstringrequired
github.event.workflow.urlstringrequired
github.event.workflow_runobjectrequired
github.event.workflow_run.actorobject or nullrequired
github.event.workflow_run.actor.avatar_urlstringoptional
github.event.workflow_run.actor.deletedbooleanoptional
github.event.workflow_run.actor.emailstring or nulloptional
github.event.workflow_run.actor.events_urlstringoptional
github.event.workflow_run.actor.followers_urlstringoptional
github.event.workflow_run.actor.following_urlstringoptional
github.event.workflow_run.actor.gists_urlstringoptional
github.event.workflow_run.actor.gravatar_idstringoptional
github.event.workflow_run.actor.html_urlstringoptional
github.event.workflow_run.actor.idintegerrequired
github.event.workflow_run.actor.loginstringrequired
github.event.workflow_run.actor.namestringoptional
github.event.workflow_run.actor.node_idstringoptional
github.event.workflow_run.actor.organizations_urlstringoptional
github.event.workflow_run.actor.received_events_urlstringoptional
github.event.workflow_run.actor.repos_urlstringoptional
github.event.workflow_run.actor.site_adminbooleanoptional
github.event.workflow_run.actor.starred_urlstringoptional
github.event.workflow_run.actor.subscriptions_urlstringoptional
github.event.workflow_run.actor.typeBot, User, Organizationoptional
github.event.workflow_run.actor.urlstringoptional
github.event.workflow_run.artifacts_urlstringrequired
github.event.workflow_run.cancel_urlstringrequired
github.event.workflow_run.check_suite_idintegerrequired
github.event.workflow_run.check_suite_node_idstringrequired
github.event.workflow_run.check_suite_urlstringrequired
github.event.workflow_run.created_atstringrequired
github.event.workflow_run.eventstringrequired
github.event.workflow_run.head_branchstring or nullrequired
github.event.workflow_run.head_commitobjectrequired
github.event.workflow_run.head_commit.authorobjectrequired

Metaproperties for Git author/committer information.

github.event.workflow_run.head_commit.author.datestringoptional
github.event.workflow_run.head_commit.author.emailstring or nullrequired
github.event.workflow_run.head_commit.author.namestringrequired

The git author’s name.

github.event.workflow_run.head_commit.author.usernamestringoptional
github.event.workflow_run.head_commit.committerobjectrequired

Metaproperties for Git author/committer information.

github.event.workflow_run.head_commit.committer.datestringoptional
github.event.workflow_run.head_commit.committer.emailstring or nullrequired
github.event.workflow_run.head_commit.committer.namestringrequired

The git author’s name.

github.event.workflow_run.head_commit.committer.usernamestringoptional
github.event.workflow_run.head_commit.idstringrequired
github.event.workflow_run.head_commit.messagestringrequired
github.event.workflow_run.head_commit.timestampstringrequired
github.event.workflow_run.head_commit.tree_idstringrequired
github.event.workflow_run.head_repositoryobjectrequired
github.event.workflow_run.head_repository.archive_urlstringrequired
github.event.workflow_run.head_repository.assignees_urlstringrequired
github.event.workflow_run.head_repository.blobs_urlstringrequired
github.event.workflow_run.head_repository.branches_urlstringrequired
github.event.workflow_run.head_repository.collaborators_urlstringrequired
github.event.workflow_run.head_repository.comments_urlstringrequired
github.event.workflow_run.head_repository.commits_urlstringrequired
github.event.workflow_run.head_repository.compare_urlstringrequired
github.event.workflow_run.head_repository.contents_urlstringrequired
github.event.workflow_run.head_repository.contributors_urlstringrequired
github.event.workflow_run.head_repository.deployments_urlstringrequired
github.event.workflow_run.head_repository.descriptionstring or nullrequired
github.event.workflow_run.head_repository.downloads_urlstringrequired
github.event.workflow_run.head_repository.events_urlstringrequired
github.event.workflow_run.head_repository.forkbooleanrequired
github.event.workflow_run.head_repository.forks_urlstringrequired
github.event.workflow_run.head_repository.full_namestringrequired
github.event.workflow_run.head_repository.git_commits_urlstringrequired
github.event.workflow_run.head_repository.git_refs_urlstringrequired
github.event.workflow_run.head_repository.git_tags_urlstringrequired
github.event.workflow_run.head_repository.hooks_urlstringrequired
github.event.workflow_run.head_repository.html_urlstringrequired
github.event.workflow_run.head_repository.idintegerrequired

Unique identifier of the repository

github.event.workflow_run.head_repository.issue_comment_urlstringrequired
github.event.workflow_run.head_repository.issue_events_urlstringrequired
github.event.workflow_run.head_repository.issues_urlstringrequired
github.event.workflow_run.head_repository.keys_urlstringrequired
github.event.workflow_run.head_repository.labels_urlstringrequired
github.event.workflow_run.head_repository.languages_urlstringrequired
github.event.workflow_run.head_repository.merges_urlstringrequired
github.event.workflow_run.head_repository.milestones_urlstringrequired
github.event.workflow_run.head_repository.namestringrequired

The name of the repository.

github.event.workflow_run.head_repository.node_idstringrequired
github.event.workflow_run.head_repository.notifications_urlstringrequired
github.event.workflow_run.head_repository.ownerobject or nullrequired
github.event.workflow_run.head_repository.owner.avatar_urlstringoptional
github.event.workflow_run.head_repository.owner.deletedbooleanoptional
github.event.workflow_run.head_repository.owner.emailstring or nulloptional
github.event.workflow_run.head_repository.owner.events_urlstringoptional
github.event.workflow_run.head_repository.owner.followers_urlstringoptional
github.event.workflow_run.head_repository.owner.following_urlstringoptional
github.event.workflow_run.head_repository.owner.gists_urlstringoptional
github.event.workflow_run.head_repository.owner.gravatar_idstringoptional
github.event.workflow_run.head_repository.owner.html_urlstringoptional
github.event.workflow_run.head_repository.owner.idintegerrequired
github.event.workflow_run.head_repository.owner.loginstringrequired
github.event.workflow_run.head_repository.owner.namestringoptional
github.event.workflow_run.head_repository.owner.node_idstringoptional
github.event.workflow_run.head_repository.owner.organizations_urlstringoptional
github.event.workflow_run.head_repository.owner.received_events_urlstringoptional
github.event.workflow_run.head_repository.owner.repos_urlstringoptional
github.event.workflow_run.head_repository.owner.site_adminbooleanoptional
github.event.workflow_run.head_repository.owner.starred_urlstringoptional
github.event.workflow_run.head_repository.owner.subscriptions_urlstringoptional
github.event.workflow_run.head_repository.owner.typeBot, User, Organizationoptional
github.event.workflow_run.head_repository.owner.urlstringoptional
github.event.workflow_run.head_repository.privatebooleanrequired

Whether the repository is private or public.

github.event.workflow_run.head_repository.pulls_urlstringrequired
github.event.workflow_run.head_repository.releases_urlstringrequired
github.event.workflow_run.head_repository.stargazers_urlstringrequired
github.event.workflow_run.head_repository.statuses_urlstringrequired
github.event.workflow_run.head_repository.subscribers_urlstringrequired
github.event.workflow_run.head_repository.subscription_urlstringrequired
github.event.workflow_run.head_repository.tags_urlstringrequired
github.event.workflow_run.head_repository.teams_urlstringrequired
github.event.workflow_run.head_repository.trees_urlstringrequired
github.event.workflow_run.head_repository.urlstringrequired
github.event.workflow_run.head_shastringrequired
github.event.workflow_run.html_urlstringrequired
github.event.workflow_run.idintegerrequired
github.event.workflow_run.jobs_urlstringrequired
github.event.workflow_run.logs_urlstringrequired
github.event.workflow_run.namestring or nullrequired
github.event.workflow_run.node_idstringrequired
github.event.workflow_run.pathstringrequired
github.event.workflow_run.previous_attempt_urlstring or nullrequired
github.event.workflow_run.pull_requestsarray of objectsrequired
github.event.workflow_run.pull_requests.baseobjectrequired
github.event.workflow_run.pull_requests.base.refstringrequired
github.event.workflow_run.pull_requests.base.repoobjectrequired
github.event.workflow_run.pull_requests.base.repo.idintegerrequired
github.event.workflow_run.pull_requests.base.repo.namestringrequired
github.event.workflow_run.pull_requests.base.repo.urlstringrequired
github.event.workflow_run.pull_requests.base.shastringrequired
github.event.workflow_run.pull_requests.headobjectrequired
github.event.workflow_run.pull_requests.head.refstringrequired
github.event.workflow_run.pull_requests.head.repoobjectrequired
github.event.workflow_run.pull_requests.head.repo.idintegerrequired
github.event.workflow_run.pull_requests.head.repo.namestringrequired
github.event.workflow_run.pull_requests.head.repo.urlstringrequired
github.event.workflow_run.pull_requests.head.shastringrequired
github.event.workflow_run.pull_requests.idnumberrequired
github.event.workflow_run.pull_requests.numbernumberrequired
github.event.workflow_run.pull_requests.urlstringrequired
github.event.workflow_run.referenced_workflowsarray of objects or nulloptional
github.event.workflow_run.referenced_workflows.pathstringrequired
github.event.workflow_run.referenced_workflows.refstringoptional
github.event.workflow_run.referenced_workflows.shastringrequired
github.event.workflow_run.repositoryobjectrequired
github.event.workflow_run.repository.archive_urlstringrequired
github.event.workflow_run.repository.assignees_urlstringrequired
github.event.workflow_run.repository.blobs_urlstringrequired
github.event.workflow_run.repository.branches_urlstringrequired
github.event.workflow_run.repository.collaborators_urlstringrequired
github.event.workflow_run.repository.comments_urlstringrequired
github.event.workflow_run.repository.commits_urlstringrequired
github.event.workflow_run.repository.compare_urlstringrequired
github.event.workflow_run.repository.contents_urlstringrequired
github.event.workflow_run.repository.contributors_urlstringrequired
github.event.workflow_run.repository.deployments_urlstringrequired
github.event.workflow_run.repository.descriptionstring or nullrequired
github.event.workflow_run.repository.downloads_urlstringrequired
github.event.workflow_run.repository.events_urlstringrequired
github.event.workflow_run.repository.forkbooleanrequired
github.event.workflow_run.repository.forks_urlstringrequired
github.event.workflow_run.repository.full_namestringrequired
github.event.workflow_run.repository.git_commits_urlstringrequired
github.event.workflow_run.repository.git_refs_urlstringrequired
github.event.workflow_run.repository.git_tags_urlstringrequired
github.event.workflow_run.repository.hooks_urlstringrequired
github.event.workflow_run.repository.html_urlstringrequired
github.event.workflow_run.repository.idintegerrequired

Unique identifier of the repository

github.event.workflow_run.repository.issue_comment_urlstringrequired
github.event.workflow_run.repository.issue_events_urlstringrequired
github.event.workflow_run.repository.issues_urlstringrequired
github.event.workflow_run.repository.keys_urlstringrequired
github.event.workflow_run.repository.labels_urlstringrequired
github.event.workflow_run.repository.languages_urlstringrequired
github.event.workflow_run.repository.merges_urlstringrequired
github.event.workflow_run.repository.milestones_urlstringrequired
github.event.workflow_run.repository.namestringrequired

The name of the repository.

github.event.workflow_run.repository.node_idstringrequired
github.event.workflow_run.repository.notifications_urlstringrequired
github.event.workflow_run.repository.ownerobject or nullrequired
github.event.workflow_run.repository.owner.avatar_urlstringoptional
github.event.workflow_run.repository.owner.deletedbooleanoptional
github.event.workflow_run.repository.owner.emailstring or nulloptional
github.event.workflow_run.repository.owner.events_urlstringoptional
github.event.workflow_run.repository.owner.followers_urlstringoptional
github.event.workflow_run.repository.owner.following_urlstringoptional
github.event.workflow_run.repository.owner.gists_urlstringoptional
github.event.workflow_run.repository.owner.gravatar_idstringoptional
github.event.workflow_run.repository.owner.html_urlstringoptional
github.event.workflow_run.repository.owner.idintegerrequired
github.event.workflow_run.repository.owner.loginstringrequired
github.event.workflow_run.repository.owner.namestringoptional
github.event.workflow_run.repository.owner.node_idstringoptional
github.event.workflow_run.repository.owner.organizations_urlstringoptional
github.event.workflow_run.repository.owner.received_events_urlstringoptional
github.event.workflow_run.repository.owner.repos_urlstringoptional
github.event.workflow_run.repository.owner.site_adminbooleanoptional
github.event.workflow_run.repository.owner.starred_urlstringoptional
github.event.workflow_run.repository.owner.subscriptions_urlstringoptional
github.event.workflow_run.repository.owner.typeBot, User, Organizationoptional
github.event.workflow_run.repository.owner.urlstringoptional
github.event.workflow_run.repository.privatebooleanrequired

Whether the repository is private or public.

github.event.workflow_run.repository.pulls_urlstringrequired
github.event.workflow_run.repository.releases_urlstringrequired
github.event.workflow_run.repository.stargazers_urlstringrequired
github.event.workflow_run.repository.statuses_urlstringrequired
github.event.workflow_run.repository.subscribers_urlstringrequired
github.event.workflow_run.repository.subscription_urlstringrequired
github.event.workflow_run.repository.tags_urlstringrequired
github.event.workflow_run.repository.teams_urlstringrequired
github.event.workflow_run.repository.trees_urlstringrequired
github.event.workflow_run.repository.urlstringrequired
github.event.workflow_run.rerun_urlstringrequired
github.event.workflow_run.run_attemptintegerrequired
github.event.workflow_run.run_numberintegerrequired
github.event.workflow_run.run_started_atstringrequired
github.event.workflow_run.triggering_actorobject or nullrequired
github.event.workflow_run.triggering_actor.avatar_urlstringoptional
github.event.workflow_run.triggering_actor.deletedbooleanoptional
github.event.workflow_run.triggering_actor.emailstring or nulloptional
github.event.workflow_run.triggering_actor.events_urlstringoptional
github.event.workflow_run.triggering_actor.followers_urlstringoptional
github.event.workflow_run.triggering_actor.following_urlstringoptional
github.event.workflow_run.triggering_actor.gists_urlstringoptional
github.event.workflow_run.triggering_actor.gravatar_idstringoptional
github.event.workflow_run.triggering_actor.html_urlstringoptional
github.event.workflow_run.triggering_actor.idintegerrequired
github.event.workflow_run.triggering_actor.loginstringrequired
github.event.workflow_run.triggering_actor.namestringoptional
github.event.workflow_run.triggering_actor.node_idstringoptional
github.event.workflow_run.triggering_actor.organizations_urlstringoptional
github.event.workflow_run.triggering_actor.received_events_urlstringoptional
github.event.workflow_run.triggering_actor.repos_urlstringoptional
github.event.workflow_run.triggering_actor.site_adminbooleanoptional
github.event.workflow_run.triggering_actor.starred_urlstringoptional
github.event.workflow_run.triggering_actor.subscriptions_urlstringoptional
github.event.workflow_run.triggering_actor.typeBot, User, Organizationoptional
github.event.workflow_run.triggering_actor.urlstringoptional
github.event.workflow_run.updated_atstringrequired
github.event.workflow_run.urlstringrequired
github.event.workflow_run.workflow_idintegerrequired
github.event.workflow_run.workflow_urlstringrequired

completed #

This event occurs when there is activity relating to a run of a GitHub Actions workflow. For more information, see "About workflows." For information about the APIs to manage workflow runs, see the GraphQL documentation or "Workflow runs" in the REST API documentation.

For activity relating to a job in a workflow run, use the workflow_job event.

To subscribe to this event, a GitHub App must have at least read-level access for the "Actions" repository permission.

fieldtyperequireddescription
github.event.actioncompletedrequired
github.event.workflow_run.conclusionsuccess, failure, neutral, cancelled, timed_out, action_required, stale, None, skippedrequired
github.event.workflow_run.statusrequested, in_progress, completed, queued, pending, waitingrequired

in_progress #

This event occurs when there is activity relating to a run of a GitHub Actions workflow. For more information, see "About workflows." For information about the APIs to manage workflow runs, see the GraphQL documentation or "Workflow runs" in the REST API documentation.

For activity relating to a job in a workflow run, use the workflow_job event.

To subscribe to this event, a GitHub App must have at least read-level access for the "Actions" repository permission.

fieldtyperequireddescription
github.event.actionin_progressrequired
github.event.workflow_run.conclusionsuccess, failure, neutral, cancelled, timed_out, action_required, stale, skipped, Nonerequired
github.event.workflow_run.statusrequested, in_progress, completed, queued, pendingrequired

requested #

This event occurs when there is activity relating to a run of a GitHub Actions workflow. For more information, see "About workflows." For information about the APIs to manage workflow runs, see the GraphQL documentation or "Workflow runs" in the REST API documentation.

For activity relating to a job in a workflow run, use the workflow_job event.

To subscribe to this event, a GitHub App must have at least read-level access for the "Actions" repository permission.

fieldtyperequireddescription
github.event.actionrequestedrequired
github.event.workflow_run.conclusionsuccess, failure, neutral, cancelled, timed_out, action_required, stale, None, skipped, startup_failurerequired
github.event.workflow_run.statusrequested, in_progress, completed, queued, pending, waitingrequired
github.event.workflow_run.display_titlestringrequired