From 29c2a9f3ef0ef69d19fe6fd7957c1e87c0ce76ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kenan=20Ali=C4=87?= Date: Fri, 17 Oct 2025 02:50:46 +0200 Subject: [PATCH] Added formatting support for ci --- .gitea/workflows/format.yml | 55 +++++++++++++++++++++++++++++++++++++ web/package.json | 1 + web/pnpm-lock.yaml | 3 ++ 3 files changed, 59 insertions(+) create mode 100644 .gitea/workflows/format.yml diff --git a/.gitea/workflows/format.yml b/.gitea/workflows/format.yml new file mode 100644 index 0000000..63ecf1a --- /dev/null +++ b/.gitea/workflows/format.yml @@ -0,0 +1,55 @@ +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 pnpm + + - name: Install packages + run: pnpm install --frozen-lockfile + working-directory: ./web + + - name: Run prettier + run: pnpm exec prettier -w **/* + working-directory: ./web + + - 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 }} diff --git a/web/package.json b/web/package.json index 7060c57..42254cc 100644 --- a/web/package.json +++ b/web/package.json @@ -30,6 +30,7 @@ "eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-refresh": "^0.4.20", "globals": "^16.4.0", + "prettier": "^3.6.2", "prettier-plugin-tailwindcss": "^0.6.14", "tw-animate-css": "^1.3.8", "typescript": "~5.8.3", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index dee2290..8689235 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -66,6 +66,9 @@ importers: globals: specifier: ^16.4.0 version: 16.4.0 + prettier: + specifier: ^3.6.2 + version: 3.6.2 prettier-plugin-tailwindcss: specifier: ^0.6.14 version: 0.6.14(prettier@3.6.2)