Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from gha-trigger/feat/support-workflow
Browse files Browse the repository at this point in the history
feat: support updating commit statuses per workflow
  • Loading branch information
suzuki-shunsuke committed Sep 19, 2022
2 parents 5a1cbdf + 567c937 commit 10f720b
Show file tree
Hide file tree
Showing 8 changed files with 1,861 additions and 505 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/index.js
README.md
39 changes: 17 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# update-commit-status-action
# commit-status-action

GitHub Actions to update commit status according to job results

Expand All @@ -10,48 +10,43 @@ jobs:
runs-on: ubuntu-latest
steps:
# Start pending
- uses: suzuki-shunsuke/update-commit-status-action@main
- uses: gha-trigger/commit-status-action@main
with:
repo_owner: suzuki-shunsuke
repo_name: test-github-action
sha: fae4b30052b48f38129f98dfc0bf3bae470eaf01
github_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
github_token: ${{secrets.PERSONAL_GITHUB_TOKEN}}

- run: sleep 20
- run: exit 1

- uses: suzuki-shunsuke/update-commit-status-action@main
- uses: gha-trigger/commit-status-action@main
if: always()
with:
repo_owner: suzuki-shunsuke
repo_name: test-github-action
sha: fae4b30052b48f38129f98dfc0bf3bae470eaf01
state: ${{ job.status }}
state: ${{job.status}}
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{secrets.PERSONAL_GITHUB_TOKEN}}
```

## Inputs

### Required

| name | description |
| ---------- | ---------------- |
| repo_owner | Repository Owner |
| repo_name | Repository Name |
| sha | Commit hash |
name | description
--- | ---
github_token (`$GITHUB_TOKEN`) | GitHub Access Token

### Optional

- github_token (`${{ github.token }}`): GitHub Access Token
- context (`${{ github.workflow }} / ${{ github.job }} (${{ github.event_name }})`):
- A string label to differentiate this status from the status of other systems. This field is case-insensitive
- repo_owner (`$GHA_REPOSITORY_OWNER`): Repository Owner
- repo_name (`$GHA_REPOSITORY_NAME`): Repository Name
- sha (`$GHA_COMMIT_STATUS_SHA`): Updated commit hash
- state (`pending`): The state of the status. Can be one of: `error`, `failure`, `pending`, `success`, `cancelled`
- target_url (`https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}`): Target URL
- context (`${{ github.workflow }} / ${{ github.job }} (${{ github.event_name }})` or `${{ github.workflow }} (${{ github.event_name }})`)
- target_url (`${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}`): Target URL
- needs: [needs context](https://docs.github.com/en/actions/learn-github-actions/contexts#needs-context)
- start_workflow (boolean): Set true if you update the commit status per workflow and you want to update the commit status in this step. You should set true in only one step

## Environment variables

- `GITHUB_TOKEN`: GitHub Access Token
- `GHA_WORKFLOW_COMMIT_STATUS `: `true` or `false`. If `true`, the commit status is updated per workflow, otherwise the commit status is updated per job

## Outputs

Expand Down
25 changes: 15 additions & 10 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
name: update-commit-status-action
name: commit-status-action
description: Update commit status according to job results
inputs:
repo_owner:
description: Repository Owner
required: true
required: false
repo_name:
description: Repository Name
required: true
required: false
sha:
description: Commit hash
required: true
required: false
github_token:
description: GitHub Access Token
required: false
target_url:
description: target URL
required: false
state:
description: A string label to differentiate this status from the status of other systems. This field is case-insensitive
required: false
default: pending
context:
description: A string label to differentiate this status from the status of other systems. This field is case-insensitive
required: false
default: ${{ github.workflow }} / ${{ github.job }} (${{ github.event_name }})
github_token:
description: GitHub Access Token
needs:
description: needs context.
required: false
default: ${{ github.token }}
target_url:
description: target URL
start_workflow:
description: Set true if you update the commit status per workflow and you want to update the commit status in this step. You should set true in only one step.
required: false
default: false
runs:
using: node16
main: dist/index.js
13 changes: 13 additions & 0 deletions dist/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 10f720b

Please sign in to comment.