-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add a scheduled job to automatically bump pre-commit hook vers…
…ions
- Loading branch information
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |