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

Commit 10f720b

Browse files
Merge pull request #7 from gha-trigger/feat/support-workflow
feat: support updating commit statuses per workflow
2 parents 5a1cbdf + 567c937 commit 10f720b

File tree

8 files changed

+1861
-505
lines changed

8 files changed

+1861
-505
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
dist/index.js
2+
README.md

README.md

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# update-commit-status-action
1+
# commit-status-action
22

33
GitHub Actions to update commit status according to job results
44

@@ -10,48 +10,43 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
# Start pending
13-
- uses: suzuki-shunsuke/update-commit-status-action@main
13+
- uses: gha-trigger/commit-status-action@main
1414
with:
15-
repo_owner: suzuki-shunsuke
16-
repo_name: test-github-action
17-
sha: fae4b30052b48f38129f98dfc0bf3bae470eaf01
18-
github_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
15+
github_token: ${{secrets.PERSONAL_GITHUB_TOKEN}}
1916

2017
- run: sleep 20
2118
- run: exit 1
2219

23-
- uses: suzuki-shunsuke/update-commit-status-action@main
20+
- uses: gha-trigger/commit-status-action@main
2421
if: always()
2522
with:
26-
repo_owner: suzuki-shunsuke
27-
repo_name: test-github-action
28-
sha: fae4b30052b48f38129f98dfc0bf3bae470eaf01
29-
state: ${{ job.status }}
23+
state: ${{job.status}}
3024
env:
31-
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
25+
GITHUB_TOKEN: ${{secrets.PERSONAL_GITHUB_TOKEN}}
3226
```
3327
3428
## Inputs
3529
3630
### Required
3731
38-
| name | description |
39-
| ---------- | ---------------- |
40-
| repo_owner | Repository Owner |
41-
| repo_name | Repository Name |
42-
| sha | Commit hash |
32+
name | description
33+
--- | ---
34+
github_token (`$GITHUB_TOKEN`) | GitHub Access Token
4335

4436
### Optional
4537

46-
- github_token (`${{ github.token }}`): GitHub Access Token
47-
- context (`${{ github.workflow }} / ${{ github.job }} (${{ github.event_name }})`):
48-
- A string label to differentiate this status from the status of other systems. This field is case-insensitive
38+
- repo_owner (`$GHA_REPOSITORY_OWNER`): Repository Owner
39+
- repo_name (`$GHA_REPOSITORY_NAME`): Repository Name
40+
- sha (`$GHA_COMMIT_STATUS_SHA`): Updated commit hash
4941
- state (`pending`): The state of the status. Can be one of: `error`, `failure`, `pending`, `success`, `cancelled`
50-
- target_url (`https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}`): Target URL
42+
- context (`${{ github.workflow }} / ${{ github.job }} (${{ github.event_name }})` or `${{ github.workflow }} (${{ github.event_name }})`)
43+
- target_url (`${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}`): Target URL
44+
- needs: [needs context](https://docs.github.com/en/actions/learn-github-actions/contexts#needs-context)
45+
- 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
5146

5247
## Environment variables
5348

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

5651
## Outputs
5752

action.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
name: update-commit-status-action
1+
name: commit-status-action
22
description: Update commit status according to job results
33
inputs:
44
repo_owner:
55
description: Repository Owner
6-
required: true
6+
required: false
77
repo_name:
88
description: Repository Name
9-
required: true
9+
required: false
1010
sha:
1111
description: Commit hash
12-
required: true
12+
required: false
13+
github_token:
14+
description: GitHub Access Token
15+
required: false
16+
target_url:
17+
description: target URL
18+
required: false
1319
state:
1420
description: A string label to differentiate this status from the status of other systems. This field is case-insensitive
1521
required: false
1622
default: pending
1723
context:
1824
description: A string label to differentiate this status from the status of other systems. This field is case-insensitive
1925
required: false
20-
default: ${{ github.workflow }} / ${{ github.job }} (${{ github.event_name }})
21-
github_token:
22-
description: GitHub Access Token
26+
needs:
27+
description: needs context.
2328
required: false
24-
default: ${{ github.token }}
25-
target_url:
26-
description: target URL
29+
start_workflow:
30+
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.
2731
required: false
32+
default: false
2833
runs:
2934
using: node16
3035
main: dist/index.js

dist/LICENSE

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)