Skip to content

👷 Add custom pre-commit #11

👷 Add custom pre-commit

👷 Add custom pre-commit #11

Workflow file for this run

name: Autofix
on:
# TODO: fix this
# pull_request_target:
pull_request:
jobs:
autofix:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-autofix-${{ env.pythonLocation }}-${{ hashFiles('requirements-autofix.txt', 'requirements-tests.txt') }}-v01
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-autofix.txt
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
- uses: actions/cache@v4
id: pre-commit-hooks-cache
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-hooks-${{ hashFiles('.pre-commit-config.yml') }}-v01
- run: pre-commit run --files ${{ steps.changed-files.outputs.all_changed_files }}
- name: Commit changes
if: failure()
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
git add --update
git commit -m "🎨 Autofix from pre-commit hooks"
git push
# # Allow debugging with tmate
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true
# # - name: Deploy Docs Status Pending
# # run: python ./scripts/deploy_docs_status.py
# # env:
# # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# # COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
# # RUN_ID: ${{ github.run_id }}