Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce ❌ for forks #2283

Merged
merged 7 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work for forks of forks as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will certainly try.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable 👍

looking at the diff, I think the issue could also be fixed by updating the first condition? Though that probably won't work on forks of forks.

${{ github.repository != 'primer/react'

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' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Just checking, will this only run if the target for a pull request (from a fork) is primer/react and not otherwise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow doesn't run on pull request, only push. But, yes, it will only run if the repository is primer/react.

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down