Files
kiosk/.gitea/workflows/format.yml
2025-10-24 03:09:08 +02:00

55 lines
1.2 KiB
YAML

name: Format
defaults:
run:
shell: sh
on:
pull_request:
types: [opened, synchronize]
jobs:
format:
runs-on: lts-alpine
steps:
- name: Install checkout dependencies
run: apk add git
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Install dependencies
run: apk add make jq pnpm
- name: Install packages
run: pnpm install --frozen-lockfile
working-directory: ./web
- name: Run prettier
run: make web-format
- name: Commit formatting changes
run: |
set -e
# Check if there are any changes
if git diff --quiet ./web; then
exit 0
fi
# Preserve original commit author
ORIGINAL_AUTHOR=$(git log -1 --format='%an <%ae>')
# Amend commit with formatting changes
git config user.name "Gitea Actions"
git config user.email "actions@gitea.local"
git add ./web
git commit --amend --no-edit --author="$ORIGINAL_AUTHOR"
# Force push to PR branch
git push --force-with-lease origin ${{ github.head_ref }}