Skip to content

.github/workflows/action_autoupdate.yaml #1

.github/workflows/action_autoupdate.yaml

.github/workflows/action_autoupdate.yaml #1

# adapted from https://browniebroke.com/blog/gh-action-pre-commit-autoupdate/
on:
schedule:
- cron: '0 0 * * *'
jobs:
auto-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Git switch to new branch
run: git switch --create=${{ github.run_id }}-${{ github.run_attempt }}
- name: Install pre-commit
run: python -m pip install pre-commit
- name: Run pre-commit autoupdate
run: pre-commit autoupdate
- name: check for changes
id: check-changes
run: |
if git diff --exit-code; then
echo "changes_exist=true" >> "$GITHUB_OUTPUT"
else
echo "changes_exist=false" >> "$GITHUB_OUTPUT"
fi
- name: Create pull request
if: ${{steps.check-changes.outputs.changes_exist}}
run: |
git config --global user.email "[email protected]"
git config --global user.name "Autoupdate Bot"
git add -u
git commit -m "Auto-update pre-commit hooks" -m "Update versions of tools in pre-commit configs to latest version"
git push --set-upstream origin ${{ github.run_id }}-${{ github.run_attempt }}
gh pr create --base main --title "Auto-update pre-commit hooks" --body "Update versions of tools in pre-commit configs to latest version" --assignee "karelze" --label "dependencies"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}