Skip to content

Commit b4b6376

Browse files
authored
Refactor command handler (pubnub#306)
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 ffdb745 commit b4b6376

File tree

5 files changed

+66
-128
lines changed

5 files changed

+66
-128
lines changed

.github/workflows/commands-handler.yml

+21-5
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

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ jobs:
99
check-release:
1010
name: Check release required
1111
runs-on: ubuntu-latest
12-
if: ${{ github.event.pull_request.merged && endsWith(github.repository, '-private') != true }}
12+
if: github.event.pull_request.merged && endsWith(github.repository, '-private') != true
1313
outputs:
1414
release: ${{ steps.check.outputs.ready }}
1515
steps:
1616
- name: Checkout actions
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1818
with:
1919
repository: pubnub/client-engineering-deployment-tools
2020
ref: v1
@@ -29,15 +29,15 @@ jobs:
2929
name: Publish package
3030
runs-on: ubuntu-latest
3131
needs: check-release
32-
if: ${{ needs.check-release.outputs.release == 'true' }}
32+
if: needs.check-release.outputs.release == 'true'
3333
steps:
3434
- name: Checkout repository
35-
uses: actions/checkout@v2
35+
uses: actions/checkout@v3
3636
with:
3737
# This should be the same as the one specified for on.pull_request.branches
3838
ref: master
3939
- name: Checkout actions
40-
uses: actions/checkout@v2
40+
uses: actions/checkout@v3
4141
with:
4242
repository: pubnub/client-engineering-deployment-tools
4343
ref: v1

.github/workflows/run-validations.yml

+40
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

-24
This file was deleted.

.github/workflows/validate-yml.js

-94
This file was deleted.

0 commit comments

Comments
 (0)