From 02566c7771ac064c99f40dbe0fec60c302e9b8d0 Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Tue, 18 Apr 2023 15:16:21 -0400 Subject: [PATCH] =?UTF-8?q?Reduce=20=E2=9D=8C=20for=20forks=20(#2283)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Limit deploy to has pages * Limit statuses to primer/react * Limit stale to primer/react * Preview cross org forks --------- Co-authored-by: Mike Perrotti Co-authored-by: Rez Co-authored-by: Josh Black --- .github/workflows/deploy_preview_forks.yml | 4 ++-- .github/workflows/deploy_production.yml | 12 +++++++++++- .github/workflows/stale.yml | 1 + .github/workflows/statuses.yml | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy_preview_forks.yml b/.github/workflows/deploy_preview_forks.yml index 8fdd9e95f73..3c7660e9c92 100644 --- a/.github/workflows/deploy_preview_forks.yml +++ b/.github/workflows/deploy_preview_forks.yml @@ -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: diff --git a/.github/workflows/deploy_production.yml b/.github/workflows/deploy_production.yml index 25feee63833..053a51742e0 100644 --- a/.github/workflows/deploy_production.yml +++ b/.github/workflows/deploy_production.yml @@ -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 @@ -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 }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 5e169aedefa..92bee93464a 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -6,6 +6,7 @@ on: jobs: stale: runs-on: ubuntu-latest + if: ${{ github.repository == 'primer/react' }} steps: - uses: actions/stale@v8 with: diff --git a/.github/workflows/statuses.yml b/.github/workflows/statuses.yml index 98762114cee..b742e8cecca 100644 --- a/.github/workflows/statuses.yml +++ b/.github/workflows/statuses.yml @@ -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