Skip to content

ci: release

ci: release #13112

Workflow file for this run

name: Format
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, reopened, synchronize]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
format:
name: Format
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Check formatting on main
if: github.event_name == 'push'
run: pnpm format:check
- name: Format pull request
if: github.event_name == 'pull_request'
run: pnpm format
- name: Compute formatting patch
if: github.event_name == 'pull_request'
id: patch
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
git add -A
if git diff --staged --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
mkdir -p auto-format-out
git diff --staged --binary > auto-format-out/format.patch
echo "$PR_NUMBER" > auto-format-out/pr-number
fi
- name: Upload formatting patch
if: steps.patch.outputs.changed == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: auto-format-patch
path: auto-format-out/
retention-days: 7
if-no-files-found: error
- name: Require formatted files
if: steps.patch.outputs.changed == 'true'
run: |
echo "::error::Formatting changes were required; the Auto Format — Apply workflow will push them."
exit 1