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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 5 deletions
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

Lines changed: 1 addition & 6 deletions
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/fetch-metadata@v1.1.1

0 commit comments

Comments
 (0)