mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-25 08:55:08 +00:00
Delete .github/workflows/pre-commit.yml
This commit is contained in:
parent
0bc936f749
commit
e15b9247d0
1 changed files with 0 additions and 77 deletions
77
.github/workflows/pre-commit.yml
vendored
77
.github/workflows/pre-commit.yml
vendored
|
|
@ -1,77 +0,0 @@
|
||||||
name: Pre-commit
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- develop
|
|
||||||
paths:
|
|
||||||
- "scripts/**"
|
|
||||||
- "images/**"
|
|
||||||
- "apps.json"
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- develop
|
|
||||||
workflow_dispatch: {}
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
autofix:
|
|
||||||
if: ${{ !contains(github.event.pull_request.title, '[pre-commit-fix]') && !contains(github.event.pull_request.body, '[pre-commit-fix]') }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: "3.10.6"
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
pip install pre-commit
|
|
||||||
sudo apt-get install -y jq
|
|
||||||
|
|
||||||
- name: Cache pre-commit
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pre-commit
|
|
||||||
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
|
|
||||||
restore-keys: |
|
|
||||||
pre-commit-${{ runner.os }}-
|
|
||||||
|
|
||||||
- name: Run pre-commit autofix
|
|
||||||
id: precommit
|
|
||||||
run: |
|
|
||||||
pre-commit run --from-ref origin/main --to-ref HEAD
|
|
||||||
|
|
||||||
- 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 .
|
|
||||||
|
|
||||||
map_file="msg-map.json"
|
|
||||||
default_message="chore: [pre-commit-fix] Apply pre-commit auto-fixes"
|
|
||||||
message="$default_message"
|
|
||||||
|
|
||||||
changed_files=$(git diff --cached --name-only)
|
|
||||||
for file in $changed_files; do
|
|
||||||
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"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
git commit -m "$message"
|
|
||||||
git push
|
|
||||||
Loading…
Reference in a new issue