A Github Action that allows you to wait for a Commit status to complete before continuing with a workflow.
A commit status check can take one of two forms; either a "check run" using the Github Checks API or a "commit status".
This action retrieves Commit status checks only using the GitHub Repository API.
steps:
- uses: autotelic/action-wait-for-status-check@v1
id: wait-for-status
with:
token: ${{ secrets.GITHUB_TOKEN }}
statusName: "An Expected Commit Status Context"
- name: Do something with a passing status
if: steps.wait-for-status.outputs.state == 'success'
- name: Do something with a failing status
if: steps.wait-for-status.outputs.state == 'failure'
- name: Echo Outputs
run: |
echo ${{ steps.wait-for-status.outputs.context }}
echo ${{ steps.wait-for-status.outputs.state }}
echo ${{ steps.wait-for-status.outputs.app_id }}
echo ${{ steps.wait-for-status.outputs.app_name }}
This action accepts the following parameters as inputs using the with
keyword.
-
Required
-
The GitHub token to use for making API requests. Typically, this would be set to
${{ secrets.GITHUB_TOKEN }}
.
-
Required
-
The name of the GitHub status check to wait for. For example,
build
ordeploy
.
-
Optional
-
The Git ref of the commit you want to poll for a passing status check.
-
Default context source:
github.sha
-
Note: If the action is used in a Workflow triggered by a
pull_request
event, thegithub.pull_request.head.sha
context property will be used instead.
-
Optional
-
The name of the GitHub repository you want to poll for a passing status check.
-
Default context source:
github.repo.repo
-
Optional
-
The owner of the GitHub repository you want to poll for a passing status check.
-
Default context source:
github.repo.owner
-
Optional
-
The number of seconds to wait for the status check to complete.
-
default: "600"
-
Optional
-
The number of seconds to wait before each poll of the GitHub API.
-
default: "10"
This action will output the details from the matching commit status when it is found.
All available details are listed in the GitHub API documentation here.
- Possible commit status states are
error
,failure
,pending
, orsuccess
. Additionally, the state output can returntimed_out
if the commit status was not found within the configuredtimeoutSeconds
.
- The context or "name" of the commit status found. This should exactly match the
statusName
input parameter supplied.
- The app_id attached to the commit status found.
- The app_name attached to the commit status found.
Install the dependencies
$ npm install
Build the typescript and package it for distribution
$ npm run build && npm run package
Run the tests ✔️
$ npm test
...
Action versioning workflow is based on recommendations from the Github Actions Toolkit
See the versioning documentation
On branch main
:
- Increment Package version and push tags
$ npm version [minor/patch] $ git push origin v1.1.3
- Create a GitHub release for each specific version
- Publish the specific version to the marketplace
- Move Current major version tag to new minor/patch version commit
$ git tag -fa v1 -m "Update v1 tag" $ git push origin v1 --force
On branch main
:
- Increment Package version and push tags
$ npm version major $ git push origin v2.0.0
- Create a GitHub release for each specific version
- Publish the specific version to the marketplace
- Create a new major version tag on the same commit
$ git tag -a v2 -m "Create v2 Major tag" $ git push origin v2
- Checkout the prior major version to a new release branch
$ git checkout -b releases/v1 v1 Switched to a new branch 'releases/v1'
- Make necessary patch changes and push the new releases branch to the remote
- Increment Package version and push tags
$ npm version [minor/patch] $ git push origin v1.1.4
- Create a GitHub release for each specific version
- Publish the specific version to the marketplace
- Move prior major version tag to the new minor/patch version commit
$ git tag -fa v1 -m "Update v1 tag" $ git push origin v1 --force