Skip to content

Commit 60ade0e

Browse files
committed
Factor out set-commit-status
1 parent 89b44d0 commit 60ade0e

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# .github/actions/set-commit-status/action.yml
2+
name: 'Set Commit Status'
3+
description: 'Sets the commit status for a given SHA'
4+
inputs:
5+
sha:
6+
description: 'The commit SHA to update the status for'
7+
required: true
8+
status:
9+
description: 'The status to set (pending, success, failure, error)'
10+
default: ${{ job.status }}
11+
context:
12+
description: 'The context for the status check'
13+
default: '${{ github.workflow }} / ${{ github.job }} (${{ github.event.workflow_run.event }})'
14+
description:
15+
description: 'A short description of the status'
16+
default: ${{ job.status }}
17+
token:
18+
description: 'GitHub token'
19+
default: ${{ github.token }}
20+
runs:
21+
using: 'composite'
22+
steps:
23+
- name: Set commit status
24+
uses: myrotvorets/set-commit-status-action@v2.0.1
25+
with:
26+
sha: ${{ inputs.sha }}
27+
token: ${{ inputs.token }}
28+
status: ${{ inputs.status }}
29+
context: ${{ inputs.context }}
30+
description: ${{ inputs.description }}

.github/workflows/deploy-prod.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ jobs:
1111
runs-on: ubuntu-latest
1212
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
1313
steps:
14+
- name: Attach run to the commit
15+
uses: ./.github/actions/set-commit-status
16+
with:
17+
sha: ${{ github.event.workflow_run.head_sha }}
18+
1419
- name: Checkout repository
1520
uses: actions/checkout@v4
1621

@@ -44,16 +49,22 @@ jobs:
4449
projectId: cp-algorithms
4550
channelId: live
4651

52+
53+
- name: Set final commit status
54+
uses: ./.github/actions/set-commit-status
55+
if: always()
56+
with:
57+
sha: ${{ github.event.workflow_run.head_sha }}
58+
59+
4760
deploy_github_pages:
4861
runs-on: ubuntu-latest
4962
if: github.event.workflow_run.conclusion == 'success'
5063
steps:
51-
- name: Set commit status as pending
52-
uses: myrotvorets/set-commit-status-action@v2.0.1
64+
- name: Attach run to the commit
65+
uses: ./.github/actions/set-commit-status
5366
with:
5467
sha: ${{ github.event.workflow_run.head_sha }}
55-
token: ${{ github.token }}
56-
description: ${{ job.status }}
5768

5869
- name: Checkout repository
5970
uses: actions/checkout@v4
@@ -80,10 +91,7 @@ jobs:
8091
full_commit_message: "Preview for ${{ steps.get-pr-number.outputs.pr_number != 'main' && '#' || '' }}${{ steps.get-pr-number.outputs.pr_number }} (${{ github.event.workflow_run.head_sha }}) at https://gh.cp-algorithms.com/${{ steps.get-pr-number.outputs.pr_number }}/"
8192

8293
- name: Set final commit status
83-
uses: myrotvorets/set-commit-status-action@v2.0.1
94+
uses: ./.github/actions/set-commit-status
8495
if: always()
8596
with:
8697
sha: ${{ github.event.workflow_run.head_sha }}
87-
token: ${{ github.token }}
88-
status: ${{ job.status }}
89-
description: ${{ job.status }}

0 commit comments

Comments
 (0)