Skip to content

Commit

Permalink
Reduce ❌ for forks (#2283)
Browse files Browse the repository at this point in the history
* Limit deploy to has pages

* Limit statuses to primer/react

* Limit stale to primer/react

* Preview cross org forks

---------

Co-authored-by: Mike Perrotti <mperrotti@github.com>
Co-authored-by: Rez <rezrah@github.com>
Co-authored-by: Josh Black <joshblack@github.com>
  • Loading branch information
4 people committed Apr 18, 2023
1 parent 0a8be4e commit 02566c7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy_preview_forks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ permissions:

jobs:
deploy-preview:
# target repository for pull_request is primer/react but source repository isn't primer/react
if: ${{ github.repository == 'primer/react' && github.event.pull_request.head.repo.full_name != 'primer/react' }}
# target repository for pull_request is different from source repository
if: ${{ github.repository != github.event.pull_request.head.repo.full_name }}
name: Preview
uses: primer/.github/.github/workflows/deploy_preview.yml@0cec9b9914f358846163f2428663b58da41028c9
permissions:
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
outputs:
# To avoid deploying documentation for unrelease changes, we check the number of changeset files.
# If it's 0, we deploy.
should_deploy: ${{ steps.changeset-count.outputs.change_count == 0 }}
should_deploy: ${{ steps.changeset-count.outputs.change_count == 0 && steps.has-pages.outputs.pages == 1 }}
steps:
- uses: actions/checkout@v3

Expand All @@ -28,6 +28,16 @@ jobs:
- name: Log changeset count
run: echo ${{ steps.changeset-count.outputs.change_count }}

- id: has-pages
name: Check if pages is configured
run: |
if gh api --silent https://api.github.com/repos/${{ github.repository }}/pages ; then
echo "::set-output name=pages::1"
fi
- name: Log has pages
run: echo ${{ steps.has-pages.outputs.pages }}

# Log guard output for debugging purposes
- name: Log guard output
run: echo ${{ needs.guard.outputs.should_deploy }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
jobs:
stale:
runs-on: ubuntu-latest
if: ${{ github.repository == 'primer/react' }}
steps:
- uses: actions/stale@v8
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/statuses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
jobs:
build-and-deploy:
name: Update status project
if: ${{ github.repository == 'primer/react' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down

0 comments on commit 02566c7

Please sign in to comment.