Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
check-circle

GitHub Action

wait-other-jobs

v2.0.1

wait-other-jobs

check-circle

wait-other-jobs

Waits for all or specific other jobs, even if they are defined in other workflows

Installation

Copy and paste the following snippet into your .yml file.

              

- name: wait-other-jobs

uses: kachick/[email protected]

Learn more about this action in kachick/wait-other-jobs

Choose a version

wait-other-jobs

CI Itself

This README may describe around development version, refer v2 README for latest stable version.

Overview

This action waits all GitHub Action jobs even if they are running in other workflows.
When some jobs failed, this action exit with NON 0 value. Otherwise exit with 0.

I mainly use this action for below use-case when they should run after multiple CI workflows

Usage

This is the minimum configuration.
I recommend to use timeout-minutes together with.

jobs:
  steps-with-waiting:
    # Enabling these permissions are required in private repositories
    # permissions:
    #   contents: read
    #   checks: read
    #   actions: read
    runs-on: ubuntu-latest
    steps:
      - uses: kachick/wait-other-jobs@6311df9bc725c0a5092e2db322c7cbe19165d47d # v2.0.0
        timeout-minutes: 15

You can change the token, polling interval, allow/deny list and turns early-exit as below.

with:
  github-token: "${{ secrets.YOUR_PAT }}"
  wait-seconds-before-first-polling: '30' # default '10'
  min-interval-seconds: '300' # default '15'
  retry-method: 'exponential_backoff' # default 'equal_intervals'
  early-exit: 'false' # default 'true'
  # lists should be given with JSON formatted array, do not specify both wait-list and skip-list
  #   - Each items should have "workflowFile" field and they can optinaly have "jobName" field
  #   - If no jobName is specified, all of jobs in the workflow will be targeted
  wait-list: |
    [
      {
        "workflowFile": "ci.yml",
        "jobName": "test"
      },
      {
        "workflowFile": "release.yml"
      }
    ]
  skip-list: |
    [
      {
        "workflowFile": "pages.yml"
      }
    ]

Full list of the changeable parameters

NAME DESCRIPTION TYPE REQUIRED DEFAULT OPTIONS
github-token The GITHUB_TOKEN secret. You can use PAT if you want. string true ${{ github.token }}
wait-seconds-before-first-polling Wait this interval before first polling number false 10
min-interval-seconds Wait this interval or the multiplied value (and jitter) for next polling number false 15
retry-method How to wait for next polling string false equal_intervals exponential_backoff, equal_intervals
early-exit Stop rest pollings if faced at least 1 bad condition bool false true
attempt-limits Stop rest pollings after this attempts even if other jobs are not yet completed number false 1000
wait-list This action will not wait for items other than this list string false []
skip-list This action will not wait for items on this list string false []
dry-run Avoid requests for tests bool false false

Below is a typical usecase. Assume test jobs defined in another workflow.

name: Merge bot PR after CI
on: pull_request

permissions:
  contents: write
  pull-requests: write
  # checks: read # For private repositories
  # actions: read # For private repositories

jobs:
  dependabot:
    runs-on: ubuntu-latest
    if: ${{ github.actor == 'dependabot[bot]' }}
    steps:
      - name: Dependabot metadata
        id: metadata
        uses: dependabot/fetch-metadata@c9c4182bf1b97f5224aee3906fd373f6b61b4526 # v1.6.0
      - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
      - name: Wait for other jobs to pass or fail
        if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}}
        uses: kachick/wait-other-jobs@6311df9bc725c0a5092e2db322c7cbe19165d47d # v2.0.0
        timeout-minutes: 10
      - name: Approve and merge
        if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}}
        run: gh pr review --approve "$PR_URL" && gh pr merge --auto --squash "$PR_URL"
        env:
          PR_URL: ${{github.event.pull_request.html_url}}
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

  renovate:
    runs-on: ubuntu-latest
    if: ${{ github.actor == 'renovate[bot]' }}
    steps:
      - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
      - name: Wait for other jobs to pass or fail
        uses: kachick/wait-other-jobs@6311df9bc725c0a5092e2db322c7cbe19165d47d # v2.0.0
        timeout-minutes: 10
      - name: Approve and merge
        run: gh pr review --approve "$PR_URL" && gh pr merge --auto --squash "$PR_URL"
        env:
          PR_URL: ${{github.event.pull_request.html_url}}
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

Limitations

Judge OK or Bad with the checkRun state at the moment.
When some jobs will be triggered after this action with needs: [distant-first], it might be unaccurate. (I didn't faced yet)

If any workflow starts many jobs as 100+, this action does not support it.
Because of nested paging in GraphQL makes complex. See related docs for further detail.

GITHUB_TOKEN vs PAT

This action just requires following GITHUB_TOKEN permissions. Needless annoying setup and needless unsecure around PAT.

permissions:
  contents: read # Since v2
  checks: read
  actions: read

I used a way to comment @dependabot merge in past. This is simple to ensure CI passed.
However it requires PAT(Personal Access Token).
PAT could't be reduced the permission scope to repository.
And it requires annoy steps to generate, sets and maintains tokens even if refined with beta version.

This action provides another way. It checks other workflows/jobs statuses in actions with GITHUB_TOKEN.

Cons

Why avoid automerge and platformAutomerge provided by renovate official?

automerge is slow. platformAutomerge requires many repository settings.

When you feel no issues around that, do not need to migrate to this action.
It requires many changes in repository settings around Allow auto-merge, Require status checks to pass before merging and specify the checked workflow name.
Especially specifying mandatory CI names in all personal repositories are annoy task to me.
If we are talking only about organizations, hashicorp/terraform might resolve it easier.

FAQ

Q:
What is failed to create review: Message: GitHub Actions is not permitted to approve pull requests.?

A:
Needs Allow GitHub Actions to create and approve pull requests to be enabled at https://github.com/{owner}/{repo}/settings/actions.
See GitHub Blog for further detail.

Disabled Allow GitHub Actions to create and approve pull requests

License

The scripts and documentation in this project are released under the MIT License