Skip to content

Add and update commit frequency metrics #6

Add and update commit frequency metrics

Add and update commit frequency metrics #6

# updates for dependabot PR's from pre-commit
name: dependabot pre-commit updates
on:
pull_request:
types: [opened, synchronize]
workflow_dispatch:
permissions:
pull-requests: write
contents: write
jobs:
dependabot-pre-commit-updates:
runs-on: ubuntu-latest
# Only run on Dependabot PRs
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Install python env
uses: ./.github/actions/install-python-env
with:
python-version: "3.11"
- name: Install vale dependencies
run: |
poetry run vale sync
- name: Install pre-commit
run: python -m pip install pre-commit
- name: Run pre-commit
id: pre_commit
run: pre-commit run --all-files --color=always --show-diff-on-failure
continue-on-error: true
- name: Check for changes
if: ${{ steps.pre_commit.outcome == 'failure' }}
id: check_changes
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "changes_detected=true" >> "$GITHUB_ENV"
else
echo "changes_detected=false" >> "$GITHUB_ENV"
fi
# run pre-commit again to determine if there are still issues
- name: Run pre-commit
if: ${{ env.changes_detected == 'true' &&
steps.pre_commit.outcome == 'failure' }}
run: pre-commit run --all-files --color=always --show-diff-on-failure
# raise error if there were no changes and pre-commit failed
- name: Errors detected
if: ${{ env.changes_detected == 'false' &&
steps.pre_commit.outcome == 'failure' }}
run: |
echo 'Pre-commit failed and was unable to make changes'
exit 1
# commit changes if we detected a pre-commit failure, there were changes
# and we didn't detect the pre-commit failures again.
# note: triggering this won't re-run the workflow due to the default
# behavior within GitHub and the default GitHub Token, which prevents
# looped triggers from workflow PR pushes. This is in part why
# we check for failures above, otherwise we can depend on this workflow
# to fix any challenges that don't meet repository standards.
- name: Commit and push changes
if: ${{ env.changes_detected == 'true' &&
steps.pre_commit.outcome == 'failure' }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email \
"github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "chore: auto-apply pre-commit fixes"
git push