Skip to content

Commit b1a6ad6

Browse files
committed
fix: notify on slack for master builds
1 parent 791555d commit b1a6ad6

File tree

2 files changed

+56
-157
lines changed

2 files changed

+56
-157
lines changed

.github/workflows/dhis2-verify-lib.yml

Lines changed: 16 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -34,172 +34,31 @@ jobs:
3434
runs-on: ubuntu-latest
3535
steps:
3636
- uses: actions/checkout@v2
37-
- uses: actions/setup-node@v3
38-
with:
39-
node-version: 20.x
40-
cache: 'yarn'
41-
42-
- run: |
43-
yarn install --frozen-lockfile
44-
yarn setup
45-
46-
- name: Build
47-
run: yarn build
48-
49-
- run: ./scripts/create-artifact.sh
50-
51-
- uses: actions/upload-artifact@v4
52-
with:
53-
name: lib-build
54-
path: lib-build.tar
55-
retention-days: 1
37+
- run: exit 1
5638

5739
lint:
5840
needs: [build]
5941
runs-on: ubuntu-latest
6042
steps:
61-
- uses: actions/checkout@v2
62-
- uses: actions/setup-node@v3
63-
with:
64-
node-version: 20.x
65-
cache: 'yarn'
66-
67-
- uses: actions/download-artifact@v4
68-
with:
69-
name: lib-build
70-
71-
- run: ./scripts/extract-artifact.sh
72-
73-
- run: yarn install --frozen-lockfile
74-
75-
- name: Lint
76-
run: yarn lint
77-
78-
test:
79-
runs-on: ubuntu-latest
80-
needs: [build]
81-
steps:
82-
- uses: actions/checkout@v2
83-
- uses: actions/setup-node@v3
84-
with:
85-
node-version: 20.x
86-
cache: 'yarn'
87-
88-
- uses: actions/download-artifact@v4
89-
with:
90-
name: lib-build
91-
92-
- run: ./scripts/extract-artifact.sh
93-
94-
- run: yarn install --frozen-lockfile
95-
96-
- name: Test
97-
run: yarn test
98-
99-
e2e:
100-
runs-on: ubuntu-latest
101-
if: "!github.event.push.repository.fork && github.actor != 'dependabot[bot]'"
102-
needs: [build, setup-matrix]
103-
strategy:
104-
fail-fast: false
105-
matrix:
106-
spec-group: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
107-
env:
108-
SHOULD_RECORD: ${{ contains(github.event.head_commit.message, '[e2e record]') || contains(join(github.event.pull_request.labels.*.name), 'e2e record') }}
109-
110-
steps:
111-
- name: Checkout
112-
uses: actions/checkout@v2
113-
114-
- uses: actions/setup-node@v3
115-
with:
116-
node-version: 20.x
117-
118-
- uses: actions/download-artifact@v4
119-
with:
120-
name: lib-build
121-
122-
- run: ./scripts/extract-artifact.sh
123-
124-
- name: Increase FS watchers
125-
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
126-
127-
- name: Set Cypress Record Environment Variables
128-
if: env.SHOULD_RECORD == 'true'
129-
run: |
130-
echo "CYPRESS_GROUP=e2e-${{ matrix.spec-group.id }}" >> $GITHUB_ENV
131-
echo "CYPRESS_TAG=${{ github.event_name }}" >> $GITHUB_ENV
132-
echo "CYPRESS_CI_BUILD_ID=${{ github.run_id }}" >> $GITHUB_ENV
133-
134-
- name: Debug Environment Variables
135-
run: |
136-
echo "SHOULD_RECORD=${{ env.SHOULD_RECORD }}"
137-
echo "CI Build ID=${{ github.run_id }}"
138-
echo "Group ID=e2e-${{ matrix.spec-group.id }}"
139-
echo "Spec=${{ join(matrix.spec-group.tests, ',') }}"
140-
echo "Record=${{ env.SHOULD_RECORD }}"
141-
echo "Parallel=${{ env.SHOULD_RECORD }}"
142-
echo "Computed Group=${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_GROUP || '' }}"
143-
echo "Computed Tag=${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_TAG || '' }}"
144-
echo "Computed CI Build ID=${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_CI_BUILD_ID || '' }}"
145-
146-
- name: End-to-End tests
147-
uses: cypress-io/github-action@v6
148-
with:
149-
# This should be a command that starts the server to test against.
150-
start: 'yarn cy:start'
151-
wait-on: 'http://localhost:5000'
152-
wait-on-timeout: 300
153-
record: ${{ env.SHOULD_RECORD }}
154-
parallel: ${{ env.SHOULD_RECORD }}
155-
group: ${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_GROUP || '' }}
156-
tag: ${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_TAG || '' }}
157-
ci-build-id: ${{ env.SHOULD_RECORD == 'true' && env.CYPRESS_CI_BUILD_ID || '' }}
158-
spec: ${{ join(matrix.spec-group.tests, ',') }}
159-
env:
160-
BROWSER: none
161-
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
162-
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
163-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
164-
STORYBOOK_TESTING: true
165-
166-
publish:
167-
runs-on: ubuntu-latest
168-
needs: [build, lint, test, e2e]
169-
if: "!github.event.push.repository.fork && github.actor != 'dependabot[bot]'"
170-
steps:
171-
- uses: actions/checkout@v2
172-
with:
173-
token: ${{ env.GH_TOKEN }}
174-
- uses: actions/setup-node@v3
175-
with:
176-
node-version: 20.x
177-
cache: 'yarn'
178-
179-
- uses: actions/download-artifact@v4
180-
with:
181-
name: lib-build
182-
183-
- run: ./scripts/extract-artifact.sh
184-
185-
# ensure that d2-app-scripts is available
186-
- run: yarn install --frozen-lockfile
187-
188-
- uses: dhis2/action-semantic-release@node20
189-
with:
190-
publish-npm: true
191-
publish-github: true
192-
github-token: ${{ env.GH_TOKEN }}
193-
npm-token: ${{ env.NPM_TOKEN }}
194-
43+
- run: exit 1
19544
send-slack-message:
19645
runs-on: ubuntu-latest
197-
if: ${{ always() && github.ref == 'refs/heads/master' }}
198-
needs: [build, lint, test, e2e, publish]
46+
# uses: ./.github/workflows/slack-notify.yml
47+
if: |
48+
always() &&
49+
github.ref == 'refs/heads/fix/action-slack'
50+
# needs: [build, lint, test, e2e, publish]
51+
needs: [build, lint]
19952
steps:
53+
- run: echo "${{ needs.lint.result }}"
54+
- run: echo "${{ contains(fromJson(needs.*.result), "failure") }}"
20055
- uses: rtCamp/action-slack-notify@v2
20156
env:
202-
SLACK_WEBHOOK: ${{ secrets.SLACK_BACKEND_WEBHOOK }}
57+
SLACK_USERNAME: 'dhis2-bot'
58+
SLACK_WEBHOOK: ${{ secrets.SLACK_EXTENSIBILITY_WEBHOOK }}
20359
SLACK_CHANNEL: 'team-extensibility-notifications'
60+
SLACK_MESSAGE: ${{ needs.*.result }}
20461
SLACK_MESSAGE_ON_FAILURE: 'Master branch failed to build or publish the UI library.'
205-
SLACK_COLOR: ${{ job.status }}
62+
SLACK_COLOR: ${{ needs.*.result }}
63+
64+

.github/workflows/slack-notify.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Reusable workflow example
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
notification_status:
7+
required: true
8+
type: string
9+
# secrets:
10+
# webhook:
11+
# default: ${{ secrets.SLACK_EXTENSIBILITY_WEBHOOK }}
12+
# required: true
13+
14+
jobs:
15+
send-slack-message:
16+
runs-on: ubuntu-latest
17+
# if: |
18+
# always() &&
19+
# github.ref == 'refs/heads/fix/action-slack'
20+
# # needs: [build, lint, test, e2e, publish]
21+
# needs: [build, lint]
22+
steps:
23+
- uses: rtCamp/action-slack-notify@v2
24+
with:
25+
SLACK_USERNAME: 'dhis2-bot'
26+
SLACK_CHANNEL: 'team-extensibility-notifications'
27+
SLACK_MESSAGE: ${{ inputs.notification_status }}
28+
SLACK_MESSAGE_ON_FAILURE: 'Master branch failed to build or publish the UI library.'
29+
SLACK_COLOR: ${{ inputs.notification_status }}
30+
env:
31+
SLACK_WEBHOOK: ${{ secrets.SLACK_EXTENSIBILITY_WEBHOOK }}
32+
33+
# triage:
34+
# runs-on: ubuntu-latest
35+
# steps:
36+
# - uses: actions/labeler@v4
37+
# with:
38+
# repo-token: ${{ secrets.token }}
39+
# configuration-path: ${{ inputs.config-path }}
40+

0 commit comments

Comments
 (0)