Skip to content

Merge pull request #86 from nobbi1991/bathroom_light #1

Merge pull request #86 from nobbi1991/bathroom_light

Merge pull request #86 from nobbi1991/bathroom_light #1

name: Update pre-commit hooks
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # Runs every Sunday at midnight UTC
push:
branches:
- main # Runs when changes are pushed to the main branch
jobs:
update-pre-commit-hooks:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v2
# Install pre-commit
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: Run pre-commit autoupdate
# Run pre-commit autoupdate to update the hook versions
run: pre-commit autoupdate
# Create a new branch and push changes (if the branch does not exist)
- name: Create branch and push updates
run: |
# Check if the branch exists, if not, create it
git fetch origin
BRANCH_NAME="pre-commit-updates"
if git rev-parse --verify origin/$BRANCH_NAME; then
echo "Branch $BRANCH_NAME exists, switching to it."
git checkout $BRANCH_NAME
else
echo "Branch $BRANCH_NAME does not exist, creating it."
git checkout -b $BRANCH_NAME
fi
# Add the updated .pre-commit-config.yaml file and commit changes
git add .pre-commit-config.yaml
git commit -m 'Update pre-commit hook versions'
# Push the changes to the branch
git push -u origin $BRANCH_NAME