-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test GitHub Action for formatting CMS markdown content
- Loading branch information
1 parent
d3cdfdd
commit 7e9afb8
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Format CMS Content | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
# branches: | ||
# - "cms/*" | ||
paths: | ||
- "**/*.md" | ||
|
||
jobs: | ||
format: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: apps/site | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: "npm" | ||
|
||
- name: Install dependencies | ||
run: npm install --prefer-offline || npm install --prefer-offline | ||
|
||
- name: Format Markdown files | ||
run: | | ||
git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep '\.md$' | xargs -I {} npx prettier --write {} --config .prettierrc.json | ||
- name: Commit changes | ||
run: | | ||
if [[ -n "$(git status --porcelain)" ]]; then | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git add -A | ||
git commit -m "chore: format markdown content" | ||
git push | ||
else | ||
echo "No changes to commit" | ||
fi |