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
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
🌐
GitHub
docs.github.com › en › actions › tutorials › create-an-example-workflow
Creating an example workflow - GitHub Docs
If this field is omitted, the name of the workflow file will be used instead. 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. This example uses an expression with the `github` context to display the username of the actor that triggered the workflow run.
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
Git newbie: What is a good workflow for a solo/small team on a WIP project (many and fast releases)?

Git is a very powerful tool. If you use its full power, you can benefit a lot from it.

I am assuming that you're using GitHub to host your code. My suggestion for a good workflow would be: (assuming you already have setup your repo on GitHub and your code is on the master branch)

  1. Pull in the code onto your machine by using the command git pull origin master.

  2. Create a new branch for changes you want to make using git checkout -b new_branch_name

  3. Make changes or add new code.

  4. git diff your code and verify that the changes you have are the desired ones.

  5. git add . (Although many developers prefer not adding all the files directly). If you want to be extra careful while staging your files, use git add -i. This will start an interactive session.

  6. git commit -m "Good, sensible, imperative commit message".

  7. git push origin new_branch_name

  8. From your new_branch_name branch on GitHub, send a pull request to merge onto your master branch. Your pull request will act as a place to review your code. Your team-mates can review your code and suggest necessary changes.

  9. If everything is fine, switch to master branch locally and pull in the latest changes using the following commands: git checkout master --> git pull origin master --> git merge new_branch_name. One thing that needs to be taken care of here would be that it is always a better practice to merge master branch onto your new_branch_name and resolve conflicts and then merge this code back onto master after testing the new_branch_name branch and making sure all your tests pass.

  10. Once the merged, conflict resolved, test passing code is on master, push the changes to master branch by using the command git push origin master.

BONUS: If you have a git based deployment system, create a branch called production and merge your changes from master onto production by git checkout -b production && git merge master && git push origin production. Now this will be the only code you'll use to pull on your production setup.

The thing about this sort of workflow is that it will scale. When your team grows, you can still follow the same workflow. This is more or less how a basic Git workflow would be like. Hope that was what you were looking for.

EDIT: Thanks to "tchebb", I've updated the 6th point. When manually staging (git add .) all the files, you can commit the changes using only the -m flag.

More on reddit.com
🌐 r/webdev
28
25
August 31, 2012
Testing Github workflows
Just do dumb shirt commit messages on a branch then squash them into a single commit before merging into master More on reddit.com
🌐 r/devops
33
52
February 20, 2022
How do you use Git/GitHub in a professional environment
Check this post from another redditor. Post content for the lazy: I created a course where you can learn a professional Git team workflow. You can practice it hands-on with a bot that acts as your virtual teammate. It takes around 2hrs and is completely free. Many new devs struggle with Git. And usually you start using real Git workflows only once you join a team. At least for me it was like that. I only worked on the master branch and knew the very basics of Git. And once I joined my first professional team everything felt intimidating and overwhelming. But that’s a dilemma: you can’t get experience with team workflows without joining a team. Hopefully this course helps you work around this dilemma. You can learn a professional Git workflow that is used in many real-world teams. I created a GitHub bot that acts as your virtual teammate so you get as close to real-life experience as possible. It’s a revamp of the classic Minesweeper game. Just a very slow version played in a GitHub repo with branches, pull requests, continuous integration and code reviews :) The course is completely free and takes around 2hrs to complete. You can find more information on the following page. profy.dev/project/github-minesweeper More on reddit.com
🌐 r/webdev
31
78
October 14, 2021
🌐
GitHub
docs.github.com › en › actions › reference › workflows-and-actions › workflow-commands
Workflow commands for GitHub Actions - GitHub Docs
To use environment variables in a GitHub Action, you create or modify .env files using specific GitHub Actions commands. ... name: Example Workflow for Environment Files on: push jobs: set_and_use_env_vars: runs-on: ubuntu-latest steps: - name: Set environment variable run: echo "MY_ENV_VAR=myValue" >> $GITHUB_ENV - name: Use environment variable run: | echo "The value of MY_ENV_VAR is $MY_ENV_VAR"
🌐
GitHub
docs.github.com › actions › using-workflows › events-that-trigger-workflows
Events that trigger workflows - GitHub Docs
For example, you can run a workflow when the deployment_status event occurs. ... More than one activity type triggers this event. For information about each activity type, see Webhook events and payloads.
🌐
GitHub
docs.github.com › en › rest › actions › workflow-runs
REST API endpoints for workflow runs - GitHub Docs
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/repos/OWNER/REPO/actions/runs/RUN_ID/cancel ...
🌐
GitHub
docs.github.com › actions › using-workflows › workflow-syntax-for-github-actions
Workflow syntax for GitHub Actions - GitHub Docs
The paths and paths-ignore keywords accept glob patterns that use the * and ** wildcard characters to match more than one path name. For more information, see the Workflow syntax for GitHub Actions. If at least one path matches a pattern in the paths filter, the workflow runs. For example, the following workflow would run anytime you push a JavaScript file (.js).
Find elsewhere
🌐
GitHub
docs.github.com › en › free-pro-team@latest › actions › quickstart
Quickstart for GitHub Actions - GitHub Docs
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 display, in this example "GitHub Actions Demo."
🌐
GitHub
docs.github.com › en › actions › concepts › workflows-and-actions › workflows
Workflows - GitHub Docs
These events can be: ... 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.
🌐
Everhour
everhour.com › github › github actions tutorial: complete ci/cd & workflow guide
GitHub Actions Tutorial: Complete CI/CD & Workflow Guide with Examples
December 22, 2025 - This workflow runs tests on any push or pull request. Whenever you push code or submit a PR, GitHub automatically triggers the workflow. Commit & push: Commit the file and push to GitHub. You will see a new check on pull requests or commits under the “Actions” tab. To deploy applications, combine build and deployment steps. Example: Deploy to Netlify after successful tests:
🌐
GitHub
docs.github.com › actions › managing-workflow-runs › manually-running-a-workflow
Manually running a workflow - GitHub Docs
To run a workflow, use the workflow run subcommand. Replace the workflow parameter with either the name, ID, or file name of the workflow you want to run. For example, "Link Checker", 1234567, or "link-check-test.yml".
🌐
GitHub
github.blog › home › developer skills › github for beginners: getting started with github actions
GitHub for Beginners: Getting started with GitHub Actions - The GitHub Blog
3 weeks ago - When that event fires and triggers the workflow, GitHub spins up one or more jobs that execute on a runner. GitHub then follows the steps you programmed into the workflow until it reaches the end. And it does this all on its own, without any interaction necessary on your behalf. This is essentially how the GitHub Action workflow works.
🌐
Spacelift
spacelift.io › blog › github-actions-workflows
GitHub Actions Workflows: How to Create and Manage
September 5, 2025 - GitHub Actions workflow jobs are configured by the top-level jobs property in your YAML file. This is an object where each key defines the name of a new job. The job’s settings must then be provided as a nested object: jobs: build: runs-on: ubuntu-latest steps: - name: "Check out repository" uses: actions/checkout@v3 - name: "Build project" run: "echo 'Building code...'" The example above defines a single job called build.
🌐
NimblePros
blog.nimblepros.com › blogs › using-workflow-run-in-github-actions
Using `workflow_run` in GitHub Actions | NimblePros Blog
March 1, 2023 - name: .NET Core on: workflow_dispatch: push: branches: [main] pull_request: branches: [main] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup .NET Core uses: actions/setup-dotnet@v3 with: dotnet-version: "7.x" - name: Install dependencies run: dotnet restore - name: Build id: build run: dotnet build --configuration Release --no-restore # See https://josh-ops.com/posts/github-code-coverage/ # Add coverlet.collector nuget package to test project - 'dotnet add <TestProject.cspoj> package coverlet - name: Test id: test if: steps.build.outcome == 'success' run: d
🌐
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/workflows/second_workflow.yml name: Second Workflow on: workflow_run: workflows: ["First Workflow"] types: - completed jobs: deploy: runs-on: ubuntu-latest steps: - name: Deploy run: echo "Deploying the project..." In this example, when the First Workflow completes, the Second Workflow will be triggered due to the workflow_run event.
🌐
GitHub
docs.github.com › articles › getting-started-with-github-actions
Understanding GitHub Actions - GitHub Docs
For example, you might configure multiple build jobs for different architectures without any job dependencies and a packaging job that depends on those builds. The build jobs run in parallel, and once they complete successfully, the packaging ...
🌐
GitHub
docs.github.com › actions › using-workflows › triggering-a-workflow
Triggering a workflow - GitHub Docs
The paths and paths-ignore keywords accept glob patterns that use the * and ** wildcard characters to match more than one path name. For more information, see the Workflow syntax for GitHub Actions. If at least one path matches a pattern in the paths filter, the workflow runs. For example, the following workflow would run anytime you push a JavaScript file (.js).
🌐
freeCodeCamp
freecodecamp.org › news › learn-to-use-github-actions-step-by-step-guide
Learn to Use GitHub Actions: a Step-by-Step Guide
January 16, 2025 - We’ll work with this example Action and go through it part by part below: # .github/workflows/demo.yml name: Github Action Template on: pull_request: branches: [ "main" ] schedule: - cron: '30 5,17 * * *' workflow_call: inputs: username: description: 'A username passed from the caller workflow' default: 'john-doe' required: false type: string permissions: actions: read|write|none # permissions : read|write|none # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "build" build: runs-on: ubuntu-latest # Ste
🌐
Spacelift
spacelift.io › blog › github-actions-tutorial
GitHub Actions Tutorial – Getting Started & Examples
September 15, 2025 - In the example below, we set up source code scanning for Go applications as a step in the GitHub Actions workflow. Once set up, after the checkout step, this action inspects the source code and provides results to be leveraged in the development ...