Skip to content

Commit ffa2c08

Browse files
committed
fix: dont run workflows outside of npm org (#194)
This adds a `if: github.repository_owner == 'npm'` to each workflow so they don't run outside of the npm organization by default. Closes #182
1 parent 849cecc commit ffa2c08

15 files changed

+48
-31
lines changed

.github/workflows/audit.yml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
jobs:
1212
audit:
13+
if: github.repository_owner == 'npm'
1314
runs-on: ubuntu-latest
1415
steps:
1516
- uses: actions/checkout@v3

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717

1818
jobs:
1919
lint:
20+
if: github.repository_owner == 'npm'
2021
runs-on: ubuntu-latest
2122
steps:
2223
- uses: actions/checkout@v3
@@ -34,6 +35,7 @@ jobs:
3435
- run: npm run lint
3536

3637
test:
38+
if: github.repository_owner == 'npm'
3739
strategy:
3840
fail-fast: false
3941
matrix:

.github/workflows/post-dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ permissions:
1010

1111
jobs:
1212
template-oss-apply:
13+
if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]'
1314
runs-on: ubuntu-latest
14-
if: github.actor == 'dependabot[bot]'
1515
steps:
1616
- uses: actions/checkout@v3
1717
with:

.github/workflows/pull-request.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
jobs:
1414
check:
1515
name: Check PR Title or Commits
16+
if: github.repository_owner == 'npm'
1617
runs-on: ubuntu-latest
1718
steps:
1819
- uses: actions/checkout@v3

.github/workflows/release-please.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
outputs:
1818
pr: ${{ steps.release.outputs.pr }}
1919
release: ${{ steps.release.outputs.release }}
20+
if: github.repository_owner == 'npm'
2021
runs-on: ubuntu-latest
2122
steps:
2223
- uses: actions/checkout@v3
@@ -79,7 +80,7 @@ jobs:
7980

8081
post-release:
8182
needs: release-please
82-
if: needs.release-please.outputs.release
83+
if: github.repository_owner == 'npm' && needs.release-please.outputs.release
8384
runs-on: ubuntu-latest
8485
steps:
8586
- uses: actions/checkout@v3

.github/workflows/release.yml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111

1212
jobs:
1313
lint-all:
14+
if: github.repository_owner == 'npm'
1415
runs-on: ubuntu-latest
1516
steps:
1617
- uses: actions/checkout@v3
@@ -30,6 +31,7 @@ jobs:
3031
- run: npm run lint -ws -iwr --if-present
3132

3233
test-all:
34+
if: github.repository_owner == 'npm'
3335
strategy:
3436
fail-fast: false
3537
matrix:

lib/content/_setup-job-matrix.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
if: github.repository_owner == 'npm'
12
strategy:
23
fail-fast: false
34
matrix:

lib/content/_setup-job.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
if: github.repository_owner == 'npm' {{~#if jobIf}} && {{{jobIf}}}{{/if}}
12
runs-on: ubuntu-latest
23
steps:
34
{{> setupGit}}

lib/content/audit.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,5 @@ on:
88

99
jobs:
1010
audit:
11-
runs-on: ubuntu-latest
12-
steps:
13-
{{> setupGit}}
14-
{{> setupNode}}
15-
{{> setupDeps flags="--package-lock"}}
11+
{{> setupJob flags="--package-lock"}}
1612
- run: {{rootNpmPath}} audit

lib/content/post-dependabot.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ permissions:
99

1010
jobs:
1111
template-oss-apply:
12-
runs-on: ubuntu-latest
13-
if: github.actor == 'dependabot[bot]'
14-
steps:
15-
{{> setupGit checkout=(obj ref="${{ github.event.pull_request.head_ref }}")}}
16-
{{> setupNode}}
17-
{{> setupDeps}}
12+
{{> setupJob jobIf="github.actor == 'dependabot[bot]'" checkout=(obj ref="${{ github.event.pull_request.head_ref }}")}}
1813
- name: Dependabot metadata
1914
id: metadata
2015
uses: dependabot/[email protected]

lib/content/pull-request.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ on:
1111
jobs:
1212
check:
1313
name: Check PR Title or Commits
14-
runs-on: ubuntu-latest
15-
steps:
16-
{{> setupGit checkout=(obj fetch-depth=0)}}
17-
{{> setupNode}}
18-
{{> setupDeps}}
14+
{{> setupJob checkout=(obj fetch-depth=0)}}
1915
- name: Check commits or PR title
2016
env:
2117
PR_TITLE: $\{{ github.event.pull_request.title }}

lib/content/release-please.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ jobs:
5656

5757
post-release:
5858
needs: release-please
59-
if: needs.release-please.outputs.release
60-
{{> setupJob }}
59+
{{> setupJob jobIf="needs.release-please.outputs.release" }}
6160
- name: Post release actions
6261
env:
6362
GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}

lib/content/release.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ on:
1010

1111
jobs:
1212
lint-all:
13-
runs-on: ubuntu-latest
14-
steps:
15-
{{> setupGit checkout=(obj ref="${{ inputs.ref }}")}}
16-
{{> setupNode}}
17-
{{> setupDeps}}
13+
{{> setupJob checkout=(obj ref="${{ inputs.ref }}")}}
1814
- run: {{rootNpmPath}} run lint -ws -iwr --if-present
1915

2016
test-all:

tap-snapshots/test/apply/source-snapshots.js.test.cjs

+30-5
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ on:
177177
178178
jobs:
179179
audit:
180+
if: github.repository_owner == 'npm'
180181
runs-on: ubuntu-latest
181182
steps:
182183
- uses: actions/checkout@v3
@@ -214,6 +215,7 @@ on:
214215
215216
jobs:
216217
lint:
218+
if: github.repository_owner == 'npm'
217219
runs-on: ubuntu-latest
218220
steps:
219221
- uses: actions/checkout@v3
@@ -231,6 +233,7 @@ jobs:
231233
- run: npm run lint
232234
233235
test:
236+
if: github.repository_owner == 'npm'
234237
strategy:
235238
fail-fast: false
236239
matrix:
@@ -345,8 +348,8 @@ permissions:
345348
346349
jobs:
347350
template-oss-apply:
351+
if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]'
348352
runs-on: ubuntu-latest
349-
if: github.actor == 'dependabot[bot]'
350353
steps:
351354
- uses: actions/checkout@v3
352355
with:
@@ -394,6 +397,7 @@ on:
394397
jobs:
395398
check:
396399
name: Check PR Title or Commits
400+
if: github.repository_owner == 'npm'
397401
runs-on: ubuntu-latest
398402
steps:
399403
- uses: actions/checkout@v3
@@ -438,6 +442,7 @@ jobs:
438442
outputs:
439443
pr: \${{ steps.release.outputs.pr }}
440444
release: \${{ steps.release.outputs.release }}
445+
if: github.repository_owner == 'npm'
441446
runs-on: ubuntu-latest
442447
steps:
443448
- uses: actions/checkout@v3
@@ -500,7 +505,7 @@ jobs:
500505
501506
post-release:
502507
needs: release-please
503-
if: needs.release-please.outputs.release
508+
if: github.repository_owner == 'npm' && needs.release-please.outputs.release
504509
runs-on: ubuntu-latest
505510
steps:
506511
- uses: actions/checkout@v3
@@ -536,6 +541,7 @@ on:
536541
537542
jobs:
538543
lint-all:
544+
if: github.repository_owner == 'npm'
539545
runs-on: ubuntu-latest
540546
steps:
541547
- uses: actions/checkout@v3
@@ -555,6 +561,7 @@ jobs:
555561
- run: npm run lint -ws -iwr --if-present
556562
557563
test-all:
564+
if: github.repository_owner == 'npm'
558565
strategy:
559566
fail-fast: false
560567
matrix:
@@ -963,6 +970,7 @@ on:
963970
964971
jobs:
965972
audit:
973+
if: github.repository_owner == 'npm'
966974
runs-on: ubuntu-latest
967975
steps:
968976
- uses: actions/checkout@v3
@@ -1004,6 +1012,7 @@ on:
10041012
10051013
jobs:
10061014
lint:
1015+
if: github.repository_owner == 'npm'
10071016
runs-on: ubuntu-latest
10081017
steps:
10091018
- uses: actions/checkout@v3
@@ -1021,6 +1030,7 @@ jobs:
10211030
- run: npm run lint -w a
10221031
10231032
test:
1033+
if: github.repository_owner == 'npm'
10241034
strategy:
10251035
fail-fast: false
10261036
matrix:
@@ -1099,6 +1109,7 @@ on:
10991109
11001110
jobs:
11011111
lint:
1112+
if: github.repository_owner == 'npm'
11021113
runs-on: ubuntu-latest
11031114
steps:
11041115
- uses: actions/checkout@v3
@@ -1116,6 +1127,7 @@ jobs:
11161127
- run: npm run lint -w b
11171128
11181129
test:
1130+
if: github.repository_owner == 'npm'
11191131
strategy:
11201132
fail-fast: false
11211133
matrix:
@@ -1196,6 +1208,7 @@ on:
11961208
11971209
jobs:
11981210
lint:
1211+
if: github.repository_owner == 'npm'
11991212
runs-on: ubuntu-latest
12001213
steps:
12011214
- uses: actions/checkout@v3
@@ -1213,6 +1226,7 @@ jobs:
12131226
- run: npm run lint
12141227
12151228
test:
1229+
if: github.repository_owner == 'npm'
12161230
strategy:
12171231
fail-fast: false
12181232
matrix:
@@ -1327,8 +1341,8 @@ permissions:
13271341
13281342
jobs:
13291343
template-oss-apply:
1344+
if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]'
13301345
runs-on: ubuntu-latest
1331-
if: github.actor == 'dependabot[bot]'
13321346
steps:
13331347
- uses: actions/checkout@v3
13341348
with:
@@ -1376,6 +1390,7 @@ on:
13761390
jobs:
13771391
check:
13781392
name: Check PR Title or Commits
1393+
if: github.repository_owner == 'npm'
13791394
runs-on: ubuntu-latest
13801395
steps:
13811396
- uses: actions/checkout@v3
@@ -1420,6 +1435,7 @@ jobs:
14201435
outputs:
14211436
pr: \${{ steps.release.outputs.pr }}
14221437
release: \${{ steps.release.outputs.release }}
1438+
if: github.repository_owner == 'npm'
14231439
runs-on: ubuntu-latest
14241440
steps:
14251441
- uses: actions/checkout@v3
@@ -1482,7 +1498,7 @@ jobs:
14821498
14831499
post-release:
14841500
needs: release-please
1485-
if: needs.release-please.outputs.release
1501+
if: github.repository_owner == 'npm' && needs.release-please.outputs.release
14861502
runs-on: ubuntu-latest
14871503
steps:
14881504
- uses: actions/checkout@v3
@@ -1518,6 +1534,7 @@ on:
15181534
15191535
jobs:
15201536
lint-all:
1537+
if: github.repository_owner == 'npm'
15211538
runs-on: ubuntu-latest
15221539
steps:
15231540
- uses: actions/checkout@v3
@@ -1537,6 +1554,7 @@ jobs:
15371554
- run: npm run lint -ws -iwr --if-present
15381555
15391556
test-all:
1557+
if: github.repository_owner == 'npm'
15401558
strategy:
15411559
fail-fast: false
15421560
matrix:
@@ -1964,6 +1982,7 @@ on:
19641982
19651983
jobs:
19661984
lint:
1985+
if: github.repository_owner == 'npm'
19671986
runs-on: ubuntu-latest
19681987
steps:
19691988
- uses: actions/checkout@v3
@@ -1981,6 +2000,7 @@ jobs:
19812000
- run: npm run lint -w a
19822001
19832002
test:
2003+
if: github.repository_owner == 'npm'
19842004
strategy:
19852005
fail-fast: false
19862006
matrix:
@@ -2059,6 +2079,7 @@ on:
20592079
20602080
jobs:
20612081
lint:
2082+
if: github.repository_owner == 'npm'
20622083
runs-on: ubuntu-latest
20632084
steps:
20642085
- uses: actions/checkout@v3
@@ -2076,6 +2097,7 @@ jobs:
20762097
- run: npm run lint -w b
20772098
20782099
test:
2100+
if: github.repository_owner == 'npm'
20792101
strategy:
20802102
fail-fast: false
20812103
matrix:
@@ -2150,6 +2172,7 @@ jobs:
21502172
outputs:
21512173
pr: \${{ steps.release.outputs.pr }}
21522174
release: \${{ steps.release.outputs.release }}
2175+
if: github.repository_owner == 'npm'
21532176
runs-on: ubuntu-latest
21542177
steps:
21552178
- uses: actions/checkout@v3
@@ -2212,7 +2235,7 @@ jobs:
22122235
22132236
post-release:
22142237
needs: release-please
2215-
if: needs.release-please.outputs.release
2238+
if: github.repository_owner == 'npm' && needs.release-please.outputs.release
22162239
runs-on: ubuntu-latest
22172240
steps:
22182241
- uses: actions/checkout@v3
@@ -2248,6 +2271,7 @@ on:
22482271
22492272
jobs:
22502273
lint-all:
2274+
if: github.repository_owner == 'npm'
22512275
runs-on: ubuntu-latest
22522276
steps:
22532277
- uses: actions/checkout@v3
@@ -2267,6 +2291,7 @@ jobs:
22672291
- run: npm run lint -ws -iwr --if-present
22682292
22692293
test-all:
2294+
if: github.repository_owner == 'npm'
22702295
strategy:
22712296
fail-fast: false
22722297
matrix:

0 commit comments

Comments
 (0)