Skip to content

Commit 131555f

Browse files
ci: allow approval of workflow so contributor PRs can run all tests (#407)
1 parent 25b8a2b commit 131555f

1 file changed

Lines changed: 61 additions & 4 deletions

File tree

.github/workflows/validate.yaml

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: all_packages
22
on:
33
workflow_dispatch:
4-
pull_request:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened]
56
push:
67
branches:
78
- main
@@ -11,6 +12,8 @@ jobs:
1112
runs-on: ubuntu-latest
1213
steps:
1314
- uses: actions/checkout@v2
15+
with:
16+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
1417
- uses: subosito/flutter-action@v2
1518
with:
1619
channel: 'stable'
@@ -26,21 +29,41 @@ jobs:
2629
timeout-minutes: 10
2730
steps:
2831
- uses: actions/checkout@v2
32+
with:
33+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
2934
- uses: subosito/flutter-action@v2
3035
with:
3136
channel: 'stable'
3237
- uses: bluefireteam/melos-action@v2
3338
- name: "Check formatting"
3439
run: melos run format-check
40+
3541
test_linux:
3642
runs-on: ubuntu-latest
3743
timeout-minutes: 25
38-
environment: CI Environment
44+
environment: CI Environment
3945
env:
4046
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
4147
FIREBASE_SERVICE_ACCOUNT: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
4248
steps:
49+
- name: Get User Permission
50+
id: checkAccess
51+
uses: actions-cool/check-user-permission@v2
52+
with:
53+
require: write
54+
username: ${{ github.triggering_actor }}
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
- name: Check User Permission
58+
if: steps.checkAccess.outputs.require-result == 'false'
59+
run: |
60+
echo "${{ github.triggering_actor }} does not have permissions on this repo."
61+
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
62+
echo "Job originally triggered by ${{ github.actor }}"
63+
exit 1
4364
- uses: actions/checkout@v2
65+
with:
66+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
4467
- uses: subosito/flutter-action@v2
4568
with:
4669
channel: 'stable'
@@ -61,12 +84,29 @@ jobs:
6184
test_macos:
6285
runs-on: macos-latest
6386
timeout-minutes: 25
64-
environment: CI Environment
87+
environment: CI Environment
6588
env:
6689
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
6790
FIREBASE_SERVICE_ACCOUNT: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
6891
steps:
92+
- name: Get User Permission
93+
id: checkAccess
94+
uses: actions-cool/check-user-permission@v2
95+
with:
96+
require: write
97+
username: ${{ github.triggering_actor }}
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
- name: Check User Permission
101+
if: steps.checkAccess.outputs.require-result == 'false'
102+
run: |
103+
echo "${{ github.triggering_actor }} does not have permissions on this repo."
104+
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
105+
echo "Job originally triggered by ${{ github.actor }}"
106+
exit 1
69107
- uses: actions/checkout@v2
108+
with:
109+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
70110
- uses: subosito/flutter-action@v2
71111
with:
72112
channel: 'stable'
@@ -90,12 +130,29 @@ jobs:
90130
test_windows:
91131
runs-on: windows-latest
92132
timeout-minutes: 25
93-
environment: CI Environment
133+
environment: CI Environment
94134
env:
95135
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
96136
FIREBASE_SERVICE_ACCOUNT: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
97137
steps:
138+
- name: Get User Permission
139+
id: checkAccess
140+
uses: actions-cool/check-user-permission@v2
141+
with:
142+
require: write
143+
username: ${{ github.triggering_actor }}
144+
env:
145+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
146+
- name: Check User Permission
147+
if: steps.checkAccess.outputs.require-result == 'false'
148+
run: |
149+
echo "${{ github.triggering_actor }} does not have permissions on this repo."
150+
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
151+
echo "Job originally triggered by ${{ github.actor }}"
152+
exit 1
98153
- uses: actions/checkout@v2
154+
with:
155+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
99156
- uses: subosito/flutter-action@v2
100157
with:
101158
channel: 'stable'

0 commit comments

Comments
 (0)