From 075f3533280dda8cf93dc6e3f8f58c64da712d8f Mon Sep 17 00:00:00 2001 From: Digikwal <79085106+digikwal@users.noreply.github.com> Date: Tue, 24 Jun 2025 22:16:12 +0200 Subject: [PATCH] ci: remove lint job moving lint job to separate workflow --- .github/workflows/pre-commit.yml | 62 ++++++++------------------------ 1 file changed, 14 insertions(+), 48 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index e445a679..9b92fce2 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -14,21 +14,16 @@ on: branches: - main - develop - paths: - - '.github/workflows/**' - - 'scripts/**' - - 'images/**' - - 'apps.json' workflow_dispatch: {} +permissions: + contents: write + jobs: - pre-commit: + autofix: if: ${{ !contains(github.event.pull_request.title, '[pre-commit-fix]') && !contains(github.event.pull_request.body, '[pre-commit-fix]') }} runs-on: ubuntu-latest - permissions: - contents: write - steps: - name: Checkout code uses: actions/checkout@v4 @@ -36,14 +31,16 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: 3.x + python-version: '3.10.6' - - name: Install pre-commit - run: pip install pre-commit + - name: Install dependencies + run: | + pip install pre-commit + sudo apt-get install -y jq - - name: Cache pre-commit hooks + - name: Cache pre-commit uses: actions/cache@v4 with: path: ~/.cache/pre-commit @@ -51,32 +48,25 @@ jobs: restore-keys: | pre-commit-${{ runner.os }}- - - name: Run pre-commit (autofix on changed files) + - name: Run pre-commit autofix id: precommit - continue-on-error: true run: | pre-commit run --from-ref origin/main --to-ref HEAD - - name: Install jq - run: sudo apt-get install -y jq - - - name: Push fixes back to PR + - name: Push auto-fixes back to PR if: steps.precommit.outcome == 'failure' run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add . - # Read the mapping file map_file="msg-map.json" default_message="chore: [pre-commit-fix] Apply pre-commit auto-fixes" message="$default_message" - # Dynamically determine the commit message based on changed files changed_files=$(git diff --cached --name-only) for file in $changed_files; do - ext="${file##*.}" - ext=".$ext" + ext=".$(echo "$file" | awk -F. '{print $NF}')" mapped_message=$(jq -r --arg ext "$ext" '.[$ext] // empty' "$map_file") if [ -n "$mapped_message" ]; then message="$mapped_message" @@ -86,27 +76,3 @@ jobs: git commit -m "$message" git push - - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.10.6" - - - name: Setup Go (for shfmt) - uses: actions/setup-go@v5 - with: - go-version: "^1.14" - - - name: Install pre-commit - run: pip install -U pre-commit - - - name: Lint - run: pre-commit run --color=always --all-files - env: - GO111MODULE: on