-
Notifications
You must be signed in to change notification settings - Fork 2
171 lines (145 loc) · 6.2 KB
/
Copy pathversioning.yml
File metadata and controls
171 lines (145 loc) · 6.2 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Version Bump
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
on:
workflow_run:
workflows:
- BUG Server Tests
- Module Container Tests
- BUG Client Tests
types:
- completed
branches:
- main
workflow_dispatch:
concurrency:
group: version-bump-${{ github.event.workflow_run.head_sha || github.sha }}
cancel-in-progress: true
permissions:
actions: read
contents: write
pull-requests: write
jobs:
slack-start:
name: Slack start message
runs-on: ubuntu-latest
outputs:
ts: ${{ steps.slack-start.outputs.ts }}
steps:
- name: checkout repository
uses: actions/checkout@v6
- name: send slack start message
id: slack-start
uses: ./.github/actions/slack-run-start
with:
message_prefix: Workflow running
verify-tests:
name: Verify required tests passed
runs-on: ubuntu-latest
steps:
- name: check required workflow results
id: required-tests
uses: actions/github-script@v9
with:
script: |
const requiredWorkflows = [
"test-bug-server.yml",
"test-module-container.yml",
"test-bug-client.yml",
];
const headSha = context.payload.workflow_run?.head_sha ?? context.sha;
const branch = context.payload.workflow_run?.head_branch ?? context.ref.replace("refs/heads/", "");
for (const workflowId of requiredWorkflows) {
const runs = await github.paginate(github.rest.actions.listWorkflowRuns, {
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflowId,
branch,
per_page: 100,
});
const shaRuns = runs.filter((run) => run.head_sha === headSha);
if (shaRuns.length === 0) {
core.info(`${workflowId} did not run for ${headSha}; treating it as not required for this commit.`);
continue;
}
const successfulRun = shaRuns.find((run) => (
run.status === "completed"
&& run.conclusion === "success"
));
if (!successfulRun) {
core.info(`${workflowId} has not completed successfully for ${headSha}.`);
core.setOutput("tests_passed", "false");
return;
}
}
core.setOutput("tests_passed", "true");
- name: fail when required tests are not ready
if: steps.required-tests.outputs.tests_passed != 'true'
run: |
echo "One or more relevant test workflows have not completed successfully for this SHA."
exit 1
version:
needs: verify-tests
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: setup node
uses: actions/setup-node@v6
with:
node-version: 20
cache: npm
- name: install dependencies
run: npm ci
- name: update module changelogs
run: node .github/scripts/updateModules.js
- name: commit changelog/module changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add src/modules
git diff --cached --quiet || git commit -m "ci: update module changelogs and bump versions"
git push
- name: update app changelogs
run: node .github/scripts/updateApp.js
- name: commit changelog/app changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md package.json src/client/package.json
git diff --cached --quiet || git commit -m "ci: update app changelog and bump versions"
git push
slack-finish:
name: Slack final status
if: ${{ always() && needs.slack-start.outputs.ts != '' }}
needs:
- slack-start
- verify-tests
- version
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v6
- name: set end timestamp
id: end-time
run: echo "value=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"
- name: determine workflow status
id: workflow-status
run: |
workflow_status="success"
# If the required test gate fails, delete the start notification.
if [[ "${{ needs.verify-tests.result }}" == "failure" || "${{ needs.verify-tests.result }}" == "cancelled" ]]; then
workflow_status="skipped"
elif [[ "${{ needs.version.result }}" == "failure" || "${{ needs.version.result }}" == "cancelled" ]]; then
workflow_status="failure"
fi
echo "status=$workflow_status" >> "$GITHUB_OUTPUT"
- name: update slack message
uses: ./.github/actions/slack-run-finish
with:
ts: ${{ needs.slack-start.outputs.ts }}
status: ${{ steps.workflow-status.outputs.status }}
message_prefix: Workflow