Added format support for ci

This commit is contained in:
Kenan Alić
2025-10-17 02:50:46 +02:00
parent a07020bea6
commit 97fb5175f6
3 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
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 }}

View File

@@ -34,6 +34,7 @@
"eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20", "eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.4.0", "globals": "^16.4.0",
"prettier": "^3.6.2",
"prettier-plugin-tailwindcss": "^0.6.14", "prettier-plugin-tailwindcss": "^0.6.14",
"tw-animate-css": "^1.3.8", "tw-animate-css": "^1.3.8",
"typescript": "~5.8.3", "typescript": "~5.8.3",

3
web/pnpm-lock.yaml generated
View File

@@ -78,6 +78,9 @@ importers:
globals: globals:
specifier: ^16.4.0 specifier: ^16.4.0
version: 16.4.0 version: 16.4.0
prettier:
specifier: ^3.6.2
version: 3.6.2
prettier-plugin-tailwindcss: prettier-plugin-tailwindcss:
specifier: ^0.6.14 specifier: ^0.6.14
version: 0.6.14(prettier@3.6.2) version: 0.6.14(prettier@3.6.2)