Skip to content

Commit

Permalink
Move admonitions formatting out of NPM script
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Sep 20, 2023
1 parent 2a7aaca commit e456667
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/action-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:

jobs:
format:
name: 'Format'
name: "Format"
runs-on: ubuntu-22.04
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/format')
steps:
- name: 'Post acknowledgement that it will format code'
- name: "Post acknowledgement that it will format code"
continue-on-error: true # Never fail the build if this fails
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
with:
Expand All @@ -23,27 +23,27 @@ jobs:
body: 'The "Format code" action has started running.'
})
- name: 'Download PR data'
- name: "Download PR data"
run: |
PR_DATA="/tmp/pr.json"
jq -r ".issue.pull_request.url" "$GITHUB_EVENT_PATH" | \
xargs curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -o "$PR_DATA" --url
- name: 'Check fork status'
- name: "Check fork status"
id: fork_status
run: |
IS_FORK="$(jq '.head.repo.fork' "/tmp/pr.json")"
echo "::set-output name=fork::$IS_FORK"
- name: 'Setup SSH deploy key'
- name: "Setup SSH deploy key"
if: steps.fork_status.outputs.fork == 'false'
run: |
mkdir ~/.ssh
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
- name: 'Checkout code'
- name: "Checkout code"
run: |
PR_DATA="/tmp/pr.json"
Expand All @@ -67,7 +67,7 @@ jobs:
- name: Use Node.js LTS (16.x)
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d
with:
node-version: '16'
node-version: "16"

# https://github.com/actions/cache/blob/main/examples.md#node---yarn
- name: Get yarn cache directory path
Expand All @@ -90,9 +90,9 @@ jobs:
run: yarn format-json && ruby bin/format-array.rb

- name: Format Markdown files
run: yarn format-md
run: yarn format-md && ruby bin/format-admonitions.rb

- name: 'Commit formatted code'
- name: "Commit formatted code"
run: |
# Check if there is nothing to commit (i.e. no formatting changes made)
if [ -z "$(git status --porcelain)" ]; then
Expand All @@ -109,7 +109,7 @@ jobs:
git commit -m "[CI] Format code"
git push
- name: 'Post acknowledgement that it has formatted the code'
- name: "Post acknowledgement that it has formatted the code"
continue-on-error: true # Never fail the build if this fails
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
with:
Expand All @@ -122,7 +122,7 @@ jobs:
body: 'The "Format code" action has finished running.'
})
- name: 'Post reminder to trigger build manually'
- name: "Post reminder to trigger build manually"
continue-on-error: true # Never fail the build if this fails
if: steps.fork_status.outputs.fork == 'true'
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:

- name: Verify that markdown files are formatted correctly
run: |
yarn format-md
yarn format-md && ruby bin/format-admonitions.rb
if ! git diff --quiet --exit-code; then
echo "please format the files with prettier, or apply the following changes:"
git diff
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"test": "ajv -s canonical-data.schema.json -d \"exercises/*/canonical-data.json\"",
"test-one": "ajv -s canonical-data.schema.json -d",
"format-json": "prettier --write **/*.json",
"format-md": "prettier --write **/*.md && ruby bin/format-admonitions.rb"
"format-md": "prettier --write **/*.md"
},
"resolutions": {
"minimist": "^1.2.3"
Expand Down

0 comments on commit e456667

Please sign in to comment.