To get the example to work (i.e. to have one workflow wait for another to complete) you need two files. Both files live in the .github/workflows folder of a repository.

The first file would be set up as usual. This file will be triggered by whatever event(s) are set in the on section:

---
name: Preflight

on:
  - pull_request
  - push

jobs:
  preflight-job:
    name: Preflight Step
    runs-on: ubuntu-latest
    steps:
      - run: env

The second file states that it should only trigger on the workflow_run event for any workflows with the name Preflight and must be on your repository's default branch, usually main or master:

---
name: Test

on:
  workflow_run:
    workflows:
      - Preflight
    types:
      - completed

jobs:
  test-job:
    name: Test Step
    runs-on: ubuntu-latest
    steps:
      - run: env

This more-or-less the same as the example from the GitHub Actions manual.

As you can see on the actions page of my example repo, the Preflight workflow will run first. After it has completed, the Test workflow will be triggered:

When you try this out, you will find that the Test workflow always runs the code and workflow configuration on your default branch, usually main or master.

This is because, (quoting from the manual):

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

This means you'll need to develop workflows triggered by workflow_run on your default branch, which is a little unfortunate.

This also means that if you need the "Test" workflow to run against the code of your branch or pull request, then you'll need to do more work as described below:

Every actions is run with a set of contexts. The github context holds information about the event that triggered the workflow. This includes the branch that the event was originally triggered from/for: github.event.workflow_run.head_branch.

This can be used to check out the origination branch in the action, using the actions/checkout action provided by GitHub.

To do this, the Yaml would be:

---
name: Test

on:
  workflow_run:
    workflows:
      - Preflight
    types:
      - completed

jobs:
  test-job:
    name: Test Step
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          repository: '${{ github.event.workflow_run.head_repository.full_name }}'
          ref: ${{ github.event.workflow_run.head_branch }}
      - run: git branch
      - run: env
Answer from Potherca on Stack Overflow
🌐
GitHub
docs.github.com › actions › using-workflows › workflow-syntax-for-github-actions
Workflow syntax for GitHub Actions - GitHub Docs
If you omit name, GitHub displays ... workflow runs generated from the workflow. GitHub displays the workflow run name in the list of workflow runs on your repository's "Actions" tab....
Top answer
1 of 1
67

To get the example to work (i.e. to have one workflow wait for another to complete) you need two files. Both files live in the .github/workflows folder of a repository.

The first file would be set up as usual. This file will be triggered by whatever event(s) are set in the on section:

---
name: Preflight

on:
  - pull_request
  - push

jobs:
  preflight-job:
    name: Preflight Step
    runs-on: ubuntu-latest
    steps:
      - run: env

The second file states that it should only trigger on the workflow_run event for any workflows with the name Preflight and must be on your repository's default branch, usually main or master:

---
name: Test

on:
  workflow_run:
    workflows:
      - Preflight
    types:
      - completed

jobs:
  test-job:
    name: Test Step
    runs-on: ubuntu-latest
    steps:
      - run: env

This more-or-less the same as the example from the GitHub Actions manual.

As you can see on the actions page of my example repo, the Preflight workflow will run first. After it has completed, the Test workflow will be triggered:

When you try this out, you will find that the Test workflow always runs the code and workflow configuration on your default branch, usually main or master.

This is because, (quoting from the manual):

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

This means you'll need to develop workflows triggered by workflow_run on your default branch, which is a little unfortunate.

This also means that if you need the "Test" workflow to run against the code of your branch or pull request, then you'll need to do more work as described below:

Every actions is run with a set of contexts. The github context holds information about the event that triggered the workflow. This includes the branch that the event was originally triggered from/for: github.event.workflow_run.head_branch.

This can be used to check out the origination branch in the action, using the actions/checkout action provided by GitHub.

To do this, the Yaml would be:

---
name: Test

on:
  workflow_run:
    workflows:
      - Preflight
    types:
      - completed

jobs:
  test-job:
    name: Test Step
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          repository: '${{ github.event.workflow_run.head_repository.full_name }}'
          ref: ${{ github.event.workflow_run.head_branch }}
      - run: git branch
      - run: env
Discussions

Using `workflow_run` in pull requests from non-default branches or forks
Select Topic Area Question Body I'm working a python repository, where I am using pre-commit. I have one workflow that runs code quality checks, and a set of other workflows (>=1) that will ... More on github.com
🌐 github.com
2
2
GitHub Actions API: Get view workflow run history - Stack Overflow
I am looking for an API to retrieve previous runs of a specific workflow in GitHub Actions. I found the API that returns the previous runs of my entire repository, but I only need the runs of a spe... More on stackoverflow.com
🌐 stackoverflow.com
Show list of currently running workflows under an account/organization
Use the GitHub API: You can use the GitHub API to programmatically retrieve information about your running workflows. Specifically, you can use the List workflow runs for a repository endpoint (https://docs.github.com/en/rest/reference/actions#list-workflow-runs-for-a-repository) to retrieve ... More on github.com
🌐 github.com
5
8
March 17, 2023
What is a GitHub "Workflow" and how does it differ from an "Action"?
An action is a song. A workflow is a playlist. More on reddit.com
🌐 r/github
15
26
November 10, 2023
🌐
GitHub
docs.github.com › en › rest › actions › workflow-runs
REST API endpoints for workflow runs - GitHub Docs
Refer to "Actions Get workflow usage and Get workflow run usage endpoints closing down" for more information. Gets the number of billable minutes and total run time for a specific workflow run. Billable minutes only apply to workflows in private repositories that use GitHub-hosted runners. Usage is listed ...
🌐
NimblePros
blog.nimblepros.com › blogs › using-workflow-run-in-github-actions
Using `workflow_run` in GitHub Actions | NimblePros Blog
March 1, 2023 - A write-access workflow_run trigger that runs after the first one does and writes the code coverage to the PR · The commenting workflow does need access to some of the files created by the first workflow, so I’ve added upload and download artifacts and am using the dawidd6/action-download-artifact action to get the artifacts from another workflow.
🌐
Medium
jiminbyun.medium.com › github-actions-workflow-run-vs-workflow-call-3f1a5c6e19d4
GitHub Actions: workflow_run vs. workflow_call | by Jimin | Medium
October 17, 2023 - # .github/workflows/first_workflow.yml name: First Workflow on: [push] jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Build run: echo "Building the project..."
🌐
GitHub
docs.github.com › actions › using-workflows › events-that-trigger-workflows
Events that trigger workflows - GitHub Docs
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.
🌐
GitHub
github.com › marketplace › actions › workflow_run-status
workflow_run status · Actions · GitHub Marketplace · GitHub
name: 'test_post' on: workflow_run: workflows: ["test"] types: - completed jobs: post-test-success: runs-on: ubuntu-latest steps: - uses: haya14busa/action-workflow_run-status@v1 - uses: actions/checkout@v2 - run: exit 0 post-test-failure: runs-on: ubuntu-latest steps: - uses: haya14busa/action-workflow_run-status@v1 - uses: actions/checkout@v2 - run: exit 1
Find elsewhere
🌐
GitHub
docs.github.com › en › actions › reference › workflows-and-actions › workflow-commands
Workflow commands for GitHub Actions - GitHub Docs
This workflow uses an imaginary secret store, secret-store, which has imaginary commands store-secret and retrieve-secret. some/secret-store@ 27b31702a0e7fc50959f5ad993c78deac1bdfc29 is an imaginary action that installs the secret-store application and configures it to connect to an instance with credentials. ... on: push jobs: secret-generator: runs-on: ubuntu-latest outputs: handle: ${{ steps.generate-secret.outputs.handle }} steps: - uses: some/secret-store@27b31702a0e7fc50959f5ad993c78deac1bdfc29 with: credentials: ${{ secrets.SECRET_STORE_CREDENTIALS }} instance: ${{ secrets.SECRET_STORE_
🌐
GitHub
docs.github.com › en › actions › concepts › workflows-and-actions › workflows
Workflows - GitHub Docs
For example, you can configure your workflow to run when a push is made to the default branch of your repository, when a release is created, or when an issue is opened. Workflow triggers are defined with the on key. For more information, see Workflow syntax for GitHub Actions.
🌐
GitHub
docs.github.com › en › actions › using-workflows › manually-running-a-workflow
Manually running a workflow - GitHub Docs
September 28, 2022 - Under your repository name, click Actions. In the left sidebar, click the name of the workflow you want to run. Above the list of workflow runs, click the Run workflow button.
🌐
GitHub
docs.github.com › en › actions › monitoring-and-troubleshooting-workflows › monitoring-workflows › viewing-workflow-run-history
Viewing workflow run history - GitHub Docs
... Read access to the repository is required to perform these steps. On GitHub, navigate to the main page of the repository. Under your repository name, click Actions. In the left sidebar, click the workflow you want to see.
🌐
Orchestra
getorchestra.io › guides › github-actions-api-list-workflow-runs-for-a-workflow
Github Actions API: List workflow runs for a workflow | Orchestra
August 25, 2024 - With the REST API, you can interact ... the List workflow runs for a workflow endpoint, which allows you to retrieve details of all workflow runs for a specific workflow....
🌐
Orchestra
getorchestra.io › guides › github-actions-api-list-jobs-for-a-workflow-run
Github Actions API: List jobs for a workflow run | Orchestra
August 24, 2024 - To retrieve job details, you first need to identify the workflow run ID. You can obtain this from the GitHub Actions tab in your repository or by using the List workflow runs endpoint.
🌐
Polpiella
polpiella.dev › github-action-workflows-side-effects
GitHub Actions workflows side effects
April 26, 2023 - One of the features that I like the most about GitHub Actions is the number of different events that you can use to trigger a workflow. Triggers are defined using the on rule in the workflow file and there is a wide range of options available such as pushes to all or specific branches or changes to a pull request. I recently learnt, thanks to this tweet from James Sherlock, that you can also use GitHub webhook events to trigger workflow runs...
🌐
GitHub
github.com › orgs › community › discussions › 102876
workflow_run triggered only on success · community · Discussion #102876
Select Topic Area Question Body name: Workflow B on: workflow_dispatch: workflow_run: workflows: ["Workflow A"] types: - completed That triggers "Workflow B" regardless of the result of "Workflow A...
🌐
Reece
reece.tech › posts › github-tracking-workflow-run
GitHub and Tracking a triggered Workflow run · reecetech
GitHub provide a neat API to List workflow runs for a repository. The API URL allows to provide a Query string with parameters.
🌐
GitHub
docs.github.com › en › actions › tutorials › create-an-example-workflow
Creating an example workflow - GitHub Docs
If this field is omitted, the name ... learn-github-actions # Optional - The name for workflow runs generated from the workflow, which will appear in the list of workflow runs on your repository's "Actions" tab....