name: Autofix on: # TODO: fix this # pull_request_target: pull_request: jobs: autofix: runs-on: ubuntu-latest permissions: contents: write pull-requests: read 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 "github-actions@github.com" 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 }}