Skip to content

Commit b7e5782

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

2 files changed

Lines changed: 198 additions & 148 deletions

File tree

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

Lines changed: 158 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,32 @@ jobs:
3030
node cypress/support/generateTestMatrix.js > matrix.json
3131
echo "::set-output name=specs::$(cat matrix.json)"
3232
33-
build:
34-
runs-on: ubuntu-latest
35-
steps:
36-
- 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
33+
# build:
34+
# runs-on: ubuntu-latest
35+
# steps:
36+
# - 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
5656

5757
lint:
58-
needs: [build]
58+
# needs: [build]
5959
runs-on: ubuntu-latest
6060
steps:
6161
- uses: actions/checkout@v2
@@ -64,142 +64,152 @@ jobs:
6464
node-version: 20.x
6565
cache: 'yarn'
6666

67-
- uses: actions/download-artifact@v4
68-
with:
69-
name: lib-build
67+
# - uses: actions/download-artifact@v4
68+
# with:
69+
# name: lib-build
7070

71-
- run: ./scripts/extract-artifact.sh
71+
# - run: ./scripts/extract-artifact.sh
7272

7373
- run: yarn install --frozen-lockfile
7474

7575
- name: Lint
7676
run: yarn lint
7777

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 }}
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 }}
194194

195195
send-slack-message:
196196
runs-on: ubuntu-latest
197-
if: ${{ always() && github.ref == 'refs/heads/master' }}
198-
needs: [build, lint, test, e2e, publish]
197+
# uses: ./.github/workflows/slack-notify.yml
198+
if: |
199+
always() &&
200+
github.ref == 'refs/heads/fix/action-slack'
201+
# needs: [build, lint, test, e2e, publish]
202+
needs: [lint]
199203
steps:
204+
- run: echo "${{ needs.lint.result }}"
205+
- run: echo "${{ needs.*.result }}"
200206
- uses: rtCamp/action-slack-notify@v2
201207
env:
202-
SLACK_WEBHOOK: ${{ secrets.SLACK_BACKEND_WEBHOOK }}
208+
SLACK_USERNAME: 'dhis2-bot'
209+
SLACK_WEBHOOK: ${{ secrets.SLACK_EXTENSIBILITY_WEBHOOK }}
203210
SLACK_CHANNEL: 'team-extensibility-notifications'
211+
SLACK_MESSAGE: ${{ needs.lint.result }}
204212
SLACK_MESSAGE_ON_FAILURE: 'Master branch failed to build or publish the UI library.'
205-
SLACK_COLOR: ${{ job.status }}
213+
SLACK_COLOR: ${{ needs.lint.result }}
214+
215+

.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)