-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (39 loc) · 1.41 KB
/
finalize-commit-status.workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: Finalize Commit Status
on:
workflow_run:
workflows:
["Backend e2e tests", "Frontend e2e tests", "Storybook Tests"]
branches: [main]
types:
- completed
jobs:
finalize-commit-status:
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- name: Check workflows statuses
id: set-is-successful
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { data: workflows } = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
head_sha: context.sha
});
const isSuccessful = workflows.workflow_runs.every(run => {
const { name, conclusion } = run;
if (name === 'Finalize Commit Status') {
return true
}
return conclusion === 'success';
});
return isSuccessful ? 'success' : 'failure';
- name: Set commit status to success if all the workflows completed successfully.
uses: guibranco/github-status-action-v2@v1.1.13
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
state: ${{ steps.set-is-successful.outputs.result }}
context: Set the commit status
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}