Skip to content

Commit

Permalink
chore: add a scheduled job to automatically bump pre-commit hook vers…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
lpm0073 committed Nov 21, 2023
1 parent 60e39c1 commit 807da7d
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/precommitVersionBumps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
#------------------------------------------------------------------------------
# Lawrence McDaniel - https://lawrencemcdaniel.com
# Version Bump Workflow for Python package openai_utils
#
# Calculate the version of the 'next' branch based on semantic-release rules.
# Compares the existing value of __version__.py to the calculated value.
# If they are different, it will update __version__.py and push the changes
# to the main branch.
#------------------------------------------------------------------------------
name: pre-commit Version Bumps

on:
schedule:
- cron: "0 0 * * 3"
workflow_dispatch:

jobs:
bump-version-next:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Checkout next branch
run: |
git checkout next
git pull origin next
- name: Set up Python
uses: actions/setup-python@v4
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: null step
run: echo "i ensure that PRECOMMIT_UPDATED is set."

- 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] .pre-commit-config.yaml [skip ci]"
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:next

0 comments on commit 807da7d

Please sign in to comment.