-
Notifications
You must be signed in to change notification settings - Fork 83
203 lines (192 loc) · 6.8 KB
/
publish.yml
File metadata and controls
203 lines (192 loc) · 6.8 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Publish
on:
workflow_dispatch:
inputs:
localfs_release_name:
description: 'localfs package version'
required: false
default: 'nightly'
localfs_ref:
description: 'localfs package ref'
required: false
workflow_run:
workflows:
- 'Tests'
branches:
- main
types:
- completed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-tests-status:
name: Check tests statuses
if: |
github.ref == 'refs/heads/main' ||
( github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' )
runs-on: ubuntu-latest
outputs:
tests_status: ${{ steps.check-tests-jobs-status.outputs.jobs_status }}
steps:
- name: Check statuses
id: check-tests-jobs-status
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
if (context.eventName === 'workflow_dispatch') {
console.log('✅ Workflow manually dispatched. Skipping tests jobs check. ✅');
core.setOutput('jobs_status', 'success');
return;
}
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id
});
const jobsToCheck = [
'Backend tests',
'Postgres tests',
'UI unit tests',
'UI EE tests',
'UI OS tests'
];
const relevantJobs = data.jobs.filter(job =>
jobsToCheck.some(jobName => job.name.startsWith(jobName))
);
const failedJobs = relevantJobs.filter(job => job.conclusion === 'failure');
const allSkippedJobs = relevantJobs.every(job => job.conclusion === 'skipped');
console.log('Relevant jobs found:', JSON.stringify(relevantJobs, null, 2));
if (failedJobs.length > 0) {
console.log('🚨 The following tests failed:');
await core.summary
.addHeading('Failed Tests 🚨');
let failedList = '';
failedJobs.forEach(job => {
console.log(`❌ ${job.name}`);
failedList += `- ❌ ${job.name}\n`;
});
await core.summary
.addRaw(failedList)
.write();
core.setOutput('jobs_status', 'failure');
} else if (allSkippedJobs) {
console.log('⏩ All tests were skipped ⏩');
await core.summary
.addHeading('Test Status ⏩')
.addRaw('All tests were skipped')
.write();
core.setOutput('jobs_status', 'skipped');
} else {
console.log('✅ Required tests passed successfully ✅');
await core.summary
.addHeading('Test Status ✅')
.addRaw('All required tests passed successfully')
.write();
core.setOutput('jobs_status', 'success');
}
publish:
if: |
needs.check-tests-status.outputs.tests_status == 'success' && github.ref == 'refs/heads/main'
needs: check-tests-status
uses: 'flowfuse/github-actions-workflows/.github/workflows/publish_node_package.yml@v0.76.0'
with:
package_name: flowfuse
build_package: true
publish_package: true
package_dependencies: |
@flowfuse/driver-localfs=nightly
secrets:
npm_registry_token: ${{ secrets.NPM_PUBLISH_TOKEN }}
sentry_auth_token: ${{ secrets.SENTRY_AUTH_TOKEN }}
sentry_organisation: ${{ secrets.SENTRY_ORGANISATION }}
sentry_project: ${{ secrets.SENTRY_PROJECT }}
dispatch_container_build:
needs: publish
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
with:
app-id: ${{ secrets.GH_BOT_APP_ID }}
private-key: ${{ secrets.GH_BOT_APP_KEY }}
owner: ${{ github.repository_owner }}
repositories: helm
- name: Trigger flowforge container build
uses: benc-uk/workflow-dispatch@7a027648b88c2413826b6ddd6c76114894dc5ec4 # v1.3.1
with:
workflow: flowforge-container.yml
repo: flowfuse/helm
ref: main
token: ${{ steps.generate_token.outputs.token }}
inputs: '{"flowforge_ref": "${{ github.ref }}", "flowforge_release_name": "${{ env.release_name }}"}'
notify-slack:
name: Notify on failure
if: failure()
needs: [check-tests-status, publish]
runs-on: ubuntu-latest
steps:
- name: Send notification
uses: slackapi/slack-github-action@03ea5433c137af7c0495bc0cad1af10403fc800c # v3.0.2
with:
method: chat.postMessage
token: ${{ secrets.SLACK_GHBOT_TOKEN }}
payload: |
{
"channel": "C067BD0377F",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: FlowFuse npm package publish pipeline failed",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "warning"
},
{
"type": "text",
"text": " Deployment to FFC environments will not happen until this issue is resolved.",
"style": {
"bold": true
}
}
]
}
]
},
{
"type": "divider"
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View Failed Workflow",
"emoji": true
},
"style": "primary",
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"value": "view_workflow"
}
]
}
]
}