From 6f0def977bab86b61ae7b098275f2e0c0d0498e9 Mon Sep 17 00:00:00 2001 From: Ameer Ghani Date: Tue, 16 Jul 2024 15:20:13 -0500 Subject: [PATCH] Fix CI when running from fork --- .github/workflows/ci-build.yml | 10 ++++++++++ README.md | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index e423400..06f593e 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -23,12 +23,21 @@ jobs: with: # Check out the branch that the PR refers to, so the git HEAD isn't detached. ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: actions/setup-node@v4 with: node-version: 18 cache: yarn - run: npx prettier --write . + - name: Check if code is unformatted + if: github.event.pull_request.head.repo.fork + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Code is not formatted properly. Please format code using 'npx prettier --write .'" + exit 1 + fi - name: Push changes + if: "!github.event.pull_request.head.repo.fork" run: | if [ -n "$(git status --porcelain)" ]; then # github-actions name and email derived from https://github.com/orgs/community/discussions/26560 @@ -53,6 +62,7 @@ jobs: # Check out the HEAD from the previous workflow, to catch any mistakes that the formatter # may have introduced. ref: "${{ needs.format.outputs.head }}" + repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: actions/setup-node@v4 with: node-version: 18 diff --git a/README.md b/README.md index 26cc43b..d2280c8 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,9 @@ Be sure to review your changes after formatting, to make sure that the formatter didn't mess up your content. This usually only happens when using the [admonition syntax](https://docusaurus.io/docs/markdown-features/admonitions#usage-with-prettier). -If you want to format your code locally, use: +If you're submitting a PR from a fork, or otherwise want to format your code +locally, use: ```bash -npx prettier --write +npx prettier --write . ```