Skip to content

pre-commit Version Bumps #64

pre-commit Version Bumps

pre-commit Version Bumps #64

---
#------------------------------------------------------------------------------
# Lawrence McDaniel - https://lawrencemcdaniel.com
# Version Bump Workflow for .pre-commit-config.yaml
#
# This workflow runs on a cron schedule and checks for updates to the
# .pre-commit-config.yaml file. If updates are found, the workflow
# commits the changes to the next branch and pushes the changes to GitHub.
#
# This is a workaround for the fact that the pre-commit autoupdate command
# is not supported by Dependabot.
#------------------------------------------------------------------------------
name: pre-commit Version Bumps
on:
schedule:
- cron: '0 0 * * 3'
workflow_dispatch:
jobs:
evaluate_precommit_config:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Checkout next branch
run: |
git fetch
git checkout next
git pull origin next
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '23.x'
- name: Preconfigure the pre-commit hook
shell: bash
run: |
npx husky add .husky/pre-commit "npx prettier --write ."
- name: Install pre-commit
shell: bash
run: yarn global add pre-commit
- name: Update .pre-commit-config.yaml
shell: bash
run: |
pre-commit autoupdate
- name: Check for unstaged changes
id: check_changes
shell: bash
run: |
if [[ -n "$(git status --porcelain .pre-commit-config.yaml)" ]]; then
echo "::set-output name=changes::true"
else
echo "::set-output name=changes::false"
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changes == 'true'
shell: bash
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .pre-commit-config.yaml
git commit -m "chore: [gh] version bumps in .pre-commit-config.yaml [skip ci]"
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:next