Skip to content

Commit

Permalink
fix: dont run workflows outside of npm org
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lukekarrys committed Sep 15, 2022
1 parent 910f3fa commit 11f801d
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 25 deletions.
1 change: 1 addition & 0 deletions .github/workflows/audit.yml
Expand Up @@ -10,6 +10,7 @@ on:

jobs:
audit:
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -17,6 +17,7 @@ on:

jobs:
lint:
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -34,6 +35,7 @@ jobs:
- run: npm run lint

test:
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post-dependabot.yml
Expand Up @@ -10,8 +10,8 @@ permissions:

jobs:
template-oss-apply:
if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- uses: actions/checkout@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yml
Expand Up @@ -13,6 +13,7 @@ on:
jobs:
check:
name: Check PR Title or Commits
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release-please.yml
Expand Up @@ -17,6 +17,7 @@ jobs:
outputs:
pr: ${{ steps.release.outputs.pr }}
release: ${{ steps.release.outputs.release }}
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -79,7 +80,7 @@ jobs:

post-release:
needs: release-please
if: needs.release-please.outputs.release
if: github.repository_owner == 'npm' && needs.release-please.outputs.release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Expand Up @@ -11,6 +11,7 @@ on:

jobs:
lint-all:
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -30,6 +31,7 @@ jobs:
- run: npm run lint -ws -iwr --if-present

test-all:
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
Expand Down
1 change: 1 addition & 0 deletions lib/content/_setup-job-matrix.yml
@@ -1,3 +1,4 @@
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
Expand Down
1 change: 1 addition & 0 deletions lib/content/_setup-job.yml
@@ -1,3 +1,4 @@
if: github.repository_owner == 'npm' {{~#if jobIf}} && {{{jobIf}}}{{/if}}
runs-on: ubuntu-latest
steps:
{{> setupGit}}
Expand Down
6 changes: 1 addition & 5 deletions lib/content/audit.yml
Expand Up @@ -8,9 +8,5 @@ on:

jobs:
audit:
runs-on: ubuntu-latest
steps:
{{> setupGit}}
{{> setupNode}}
{{> setupDeps flags="--package-lock"}}
{{> setupJob flags="--package-lock"}}
- run: {{rootNpmPath}} audit
7 changes: 1 addition & 6 deletions lib/content/post-dependabot.yml
Expand Up @@ -9,12 +9,7 @@ permissions:

jobs:
template-oss-apply:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
{{> setupGit checkout=(obj ref="${{ github.event.pull_request.head_ref }}")}}
{{> setupNode}}
{{> setupDeps}}
{{> setupJob jobIf="github.actor == 'dependabot[bot]'" checkout=(obj ref="${{ github.event.pull_request.head_ref }}")}}
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.1.1
Expand Down
6 changes: 1 addition & 5 deletions lib/content/pull-request.yml
Expand Up @@ -11,11 +11,7 @@ on:
jobs:
check:
name: Check PR Title or Commits
runs-on: ubuntu-latest
steps:
{{> setupGit checkout=(obj fetch-depth=0)}}
{{> setupNode}}
{{> setupDeps}}
{{> setupJob checkout=(obj fetch-depth=0)}}
- name: Check commits or PR title
env:
PR_TITLE: $\{{ github.event.pull_request.title }}
Expand Down
3 changes: 1 addition & 2 deletions lib/content/release-please.yml
Expand Up @@ -56,8 +56,7 @@ jobs:

post-release:
needs: release-please
if: needs.release-please.outputs.release
{{> setupJob }}
{{> setupJob jobIf="needs.release-please.outputs.release" }}
- name: Post release actions
env:
GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 1 addition & 5 deletions lib/content/release.yml
Expand Up @@ -10,11 +10,7 @@ on:

jobs:
lint-all:
runs-on: ubuntu-latest
steps:
{{> setupGit checkout=(obj ref="${{ inputs.ref }}")}}
{{> setupNode}}
{{> setupDeps}}
{{> setupJob checkout=(obj ref="${{ inputs.ref }}")}}
- run: {{rootNpmPath}} run lint -ws -iwr --if-present

test-all:
Expand Down

0 comments on commit 11f801d

Please sign in to comment.