Skip to content

Commit b8e3dbe

Browse files
authored
chore(ci): correctly validate comment author in k8s e2e job (#17818)
1 parent 812929b commit b8e3dbe

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

.github/workflows/k8s_e2e.yml

+28-29
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,31 @@ env:
4242
PROFILE: debug
4343

4444
jobs:
45+
validate:
46+
name: Validate comment
47+
runs-on: ubuntu-latest
48+
if: |
49+
github.event_name != 'issue_comment' ||
50+
( github.event.issue.pull_request &&
51+
( contains(github.event.comment.body, '/ci-run-all') ||
52+
contains(github.event.comment.body, '/ci-run-k8s')
53+
)
54+
)
55+
steps:
56+
- name: Get PR comment author
57+
id: comment
58+
uses: tspascoal/get-user-teams-membership@v2
59+
with:
60+
username: ${{ github.actor }}
61+
team: 'Vector'
62+
GITHUB_TOKEN: ${{ secrets.GH_PAT_ORG }}
63+
64+
- name: Validate author membership
65+
if: steps.comment.outputs.isTeamMember == 'false'
66+
run: exit 1
67+
4568
changes:
46-
if: github.event_name != 'issue_comment' || (github.event.issue.pull_request &&
47-
(contains(github.event.comment.body, '/ci-run-k8s') || contains(github.event.comment.body, '/ci-run-all')))
69+
needs: validate
4870
uses: ./.github/workflows/changes.yml
4971
with:
5072
base_ref: ${{ github.event.pull_request.base.ref }}
@@ -54,22 +76,14 @@ jobs:
5476
build-x86_64-unknown-linux-gnu:
5577
name: Build - x86_64-unknown-linux-gnu
5678
runs-on: [linux, ubuntu-20.04-4core]
57-
needs: changes
79+
needs: [changes, validate]
5880
if: github.event_name != 'pull_request' || needs.changes.outputs.k8s == 'true'
5981
# cargo-deb requires a release build, but we don't need optimizations for tests
6082
env:
6183
CARGO_PROFILE_RELEASE_OPT_LEVEL: 0
6284
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 256
6385
CARGO_INCREMENTAL: 0
6486
steps:
65-
- name: Validate issue comment
66-
if: github.event_name == 'issue_comment'
67-
uses: tspascoal/get-user-teams-membership@v2
68-
with:
69-
username: ${{ github.actor }}
70-
team: 'Vector'
71-
GITHUB_TOKEN: ${{ secrets.GH_PAT_ORG }}
72-
7387
- name: (PR comment) Get PR branch
7488
if: ${{ github.event_name == 'issue_comment' }}
7589
uses: xt0rted/pull-request-comment-branch@v2
@@ -127,19 +141,11 @@ jobs:
127141
compute-k8s-test-plan:
128142
name: Compute K8s test plan
129143
runs-on: ubuntu-latest
130-
needs: changes
144+
needs: [changes, validate]
131145
if: github.event_name != 'pull_request' || needs.changes.outputs.k8s == 'true'
132146
outputs:
133147
matrix: ${{ steps.set-matrix.outputs.matrix }}
134148
steps:
135-
- name: Validate issue comment
136-
if: github.event_name == 'issue_comment'
137-
uses: tspascoal/get-user-teams-membership@v2
138-
with:
139-
username: ${{ github.actor }}
140-
team: 'Vector'
141-
GITHUB_TOKEN: ${{ secrets.GH_PAT_ORG }}
142-
143149
- uses: actions/[email protected]
144150
id: set-matrix
145151
with:
@@ -189,6 +195,7 @@ jobs:
189195
name: K8s ${{ matrix.kubernetes_version.version }} / ${{ matrix.container_runtime }} (${{ matrix.kubernetes_version.role }})
190196
runs-on: [linux, ubuntu-20.04-4core]
191197
needs:
198+
- validate
192199
- build-x86_64-unknown-linux-gnu
193200
- compute-k8s-test-plan
194201
strategy:
@@ -239,21 +246,13 @@ jobs:
239246
final-result:
240247
name: K8s E2E Suite
241248
runs-on: ubuntu-latest
242-
needs: test-e2e-kubernetes
249+
needs: [test-e2e-kubernetes, validate]
243250
if: |
244251
always() && (github.event_name != 'issue_comment' || (github.event.issue.pull_request
245252
&& (contains(github.event.comment.body, '/ci-run-k8s') || contains(github.event.comment.body, '/ci-run-all'))))
246253
env:
247254
FAILED: ${{ contains(needs.*.result, 'failure') }}
248255
steps:
249-
- name: Validate issue comment
250-
if: github.event_name == 'issue_comment'
251-
uses: tspascoal/get-user-teams-membership@v2
252-
with:
253-
username: ${{ github.actor }}
254-
team: 'Vector'
255-
GITHUB_TOKEN: ${{ secrets.GH_PAT_ORG }}
256-
257256
- name: (PR comment) Get PR branch
258257
if: success() && github.event_name == 'issue_comment'
259258
uses: xt0rted/pull-request-comment-branch@v2

0 commit comments

Comments
 (0)