Skip to content

Commit

Permalink
Fix CI when running from fork
Browse files Browse the repository at this point in the history
  • Loading branch information
inahga committed Jul 16, 2024
1 parent 149e93f commit 6f0def9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file>
npx prettier --write .
```

0 comments on commit 6f0def9

Please sign in to comment.