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: Cache NPM dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node
- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: locate site-packages path
shell: bash
run: |
echo "SITE_PACKAGES_PATH=$(python -c 'import site; print(site.getsitepackages()[0])')" >> $GITHUB_ENV
- name: Install pip
shell: bash
run: |
python -m pip install --upgrade pip
- name: Install dependencies
shell: bash
run: |
pip install -r ./requirements.txt
env:
SITE_PACKAGES_PATH: ${{ env.SITE_PACKAGES_PATH }}
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: "20.9.0"
- name: Install npm dev dependencies
run: npm install
- name: Update .pre-commit-config.yaml
run: |
pre-commit autoupdate
- name: Check for unstaged changes
id: check_changes
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