Skip to content

Commit

Permalink
Test GitHub Action for formatting CMS markdown content
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlyMartin committed Feb 5, 2025
1 parent d3cdfdd commit 7e9afb8
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/format-cms-content.yml
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

0 comments on commit 7e9afb8

Please sign in to comment.