Skip to content

Commit 2edc2aa

Browse files
authored
Refactor command handler (#82)
test(github-action): refactor command handler Refactor command handler workflow to use bot name from secrets. build(workflow): improve tests and validation workflows
1 parent 3c9bd06 commit 2edc2aa

File tree

6 files changed

+83
-132
lines changed

6 files changed

+83
-132
lines changed

.github/workflows/commands-handler.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,41 @@ name: Commands processor
33
on:
44
issue_comment:
55
types: [created]
6+
defaults:
7+
run:
8+
shell: bash
69

710
jobs:
811
process:
912
name: Process command
10-
if: ${{ github.event.issue.pull_request && endsWith(github.repository, '-private') != true && startsWith(github.event.comment.body, '@client-engineering-bot ') }}
13+
if: github.event.issue.pull_request && endsWith(github.repository, '-private') != true
1114
runs-on: ubuntu-latest
1215
steps:
16+
- name: Check referred user
17+
id: user-check
18+
env:
19+
CLEN_BOT: ${{ secrets.CLEN_BOT }}
20+
run: echo "expected-user=${{ startsWith(github.event.comment.body, format('@{0} ', env.CLEN_BOT)) }}" >> $GITHUB_OUTPUT
21+
- name: Regular comment
22+
if: steps.user-check.outputs.expected-user != 'true'
23+
run: echo -e "\033[38;2;19;181;255mThis is regular commit which should be ignored.\033[0m"
1324
- name: Checkout repository
14-
uses: actions/checkout@v2
25+
if: steps.user-check.outputs.expected-user == 'true'
26+
uses: actions/checkout@v3
27+
with:
28+
token: ${{ secrets.GH_TOKEN }}
1529
- name: Checkout release actions
16-
uses: actions/checkout@v2
30+
if: steps.user-check.outputs.expected-user == 'true'
31+
uses: actions/checkout@v3
1732
with:
1833
repository: pubnub/client-engineering-deployment-tools
1934
ref: v1
2035
token: ${{ secrets.GH_TOKEN }}
2136
path: .github/.release/actions
2237
- name: Process changelog entries
38+
if: steps.user-check.outputs.expected-user == 'true'
2339
uses: ./.github/.release/actions/actions/commands
2440
with:
2541
token: ${{ secrets.GH_TOKEN }}
26-
listener: client-engineering-bot
27-
jira-api-key: ${{ secrets.JIRA_API_KEY }}
42+
listener: ${{ secrets.CLEN_BOT }}
43+
jira-api-key: ${{ secrets.JIRA_API_KEY }}

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
name: Automated product release
2-
concurrency: unity_run
32

43
on:
54
pull_request:
65
branches: [ master ]
76
types: [ closed ]
7+
concurrency: unity_run
88

99

1010
jobs:
1111
check-release:
1212
name: Check release required
1313
runs-on: ubuntu-latest
14-
if: ${{ github.event.pull_request.merged && endsWith(github.repository, '-private') != true }}
14+
if: github.event.pull_request.merged && endsWith(github.repository, '-private') != true
1515
outputs:
1616
release: ${{ steps.check.outputs.ready }}
1717
steps:
1818
- name: Checkout actions
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v3
2020
with:
2121
repository: pubnub/client-engineering-deployment-tools
2222
ref: v1
@@ -31,15 +31,15 @@ jobs:
3131
name: Build package
3232
runs-on: macos-11
3333
needs: check-release
34-
if: ${{ needs.check-release.outputs.release == 'true' }}
34+
if: needs.check-release.outputs.release == 'true'
3535
steps:
3636
- name: Checkout repository
37-
uses: actions/checkout@v2
37+
uses: actions/checkout@v3
3838
with:
3939
# This should be the same as the one specified for on.pull_request.branches
4040
ref: master
4141
- name: Checkout actions
42-
uses: actions/checkout@v2
42+
uses: actions/checkout@v3
4343
with:
4444
repository: pubnub/client-engineering-deployment-tools
4545
ref: v1

.github/workflows/run-tests.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: Tests
2-
concurrency: unity_run
32

43
on:
54
push:
65
workflow_dispatch:
6+
concurrency: unity_run
7+
defaults:
8+
run:
9+
shell: bash
710

811
jobs:
912
tests:
@@ -18,9 +21,9 @@ jobs:
1821
PAM_SECRET_KEY: ${{ secrets.PAM_SECRET_KEY }}
1922
steps:
2023
- name: Checkout repository
21-
uses: actions/checkout@v2
24+
uses: actions/checkout@v3
2225
- name: Checkout actions
23-
uses: actions/checkout@v2
26+
uses: actions/checkout@v3
2427
with:
2528
repository: pubnub/client-engineering-deployment-tools
2629
ref: v1
@@ -46,3 +49,13 @@ jobs:
4649
license-username: ${{ secrets.UNITYCI_NEW_USER }}
4750
license-password: ${{ secrets.UNITYCI_NEW_PASS }}
4851
license-serial: ${{ secrets.UNITYCI_NEW_SERIAL }}
52+
- name: Cancel workflow runs for commit on error
53+
if: failure()
54+
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
55+
all-tests:
56+
name: Tests
57+
runs-on: ubuntu-latest
58+
needs: [tests]
59+
steps:
60+
- name: Tests summary
61+
run: echo -e "\033[38;2;95;215;0m\033[1mAll tests successfully passed"

.github/workflows/run-validations.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Validations
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
jobs:
14+
pubnub-yml:
15+
name: "Validate .pubnub.yml"
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout project
19+
uses: actions/checkout@v3
20+
- name: Checkout validator action
21+
uses: actions/checkout@v3
22+
with:
23+
repository: pubnub/client-engineering-deployment-tools
24+
ref: v1
25+
token: ${{ secrets.GH_TOKEN }}
26+
path: .github/.release/actions
27+
- name: "Run '.pubnub.yml' file validation"
28+
uses: ./.github/.release/actions/actions/validators/pubnub-yml
29+
with:
30+
token: ${{ secrets.GH_TOKEN }}
31+
- name: Cancel workflow runs for commit on error
32+
if: failure()
33+
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
34+
all-validations:
35+
name: Validations
36+
runs-on: ubuntu-latest
37+
needs: [pubnub-yml]
38+
steps:
39+
- name: Validations summary
40+
run: echo -e "\033[38;2;95;215;0m\033[1mAll validations passed"

.github/workflows/validate-pubnub-yml.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/validate-yml.js

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)