Skip to content

Commit d2d8a9f

Browse files
Enable automated dependabot pre-commit updates (#136)
* enable automated dependabot updates * [pre-commit.ci lite] apply automatic fixes * Update dependabot.yml * [pre-commit.ci lite] apply automatic fixes * Update .pre-commit-config.yaml * Update run-tests.yml --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 3a77675 commit d2d8a9f

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

.github/workflows/dependabot.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: dependabot jobs
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
permissions:
8+
pull-requests: write
9+
contents: write
10+
11+
jobs:
12+
pre-commit:
13+
if: github.actor == 'dependabot[bot]'
14+
runs-on: ubuntu-24.04
15+
steps:
16+
# checks out the repo
17+
- uses: actions/checkout@v5
18+
with:
19+
# fetch tags for versioning details
20+
fetch-depth: 0
21+
# Check out the branch that Dependabot’s PR is coming from
22+
ref: ${{ github.event.pull_request.head.ref }}
23+
repository: ${{ github.event.pull_request.head.repo.full_name }}
24+
persist-credentials: true
25+
- name: Fetch tags
26+
run: git fetch --all --tags
27+
- name: Python setup
28+
uses: actions/setup-python@v6
29+
with:
30+
python-version: "3.11"
31+
- name: Setup for poetry
32+
run: |
33+
python -m pip install poetry
34+
poetry self add "poetry-dynamic-versioning[plugin]"
35+
- name: Install environment
36+
run: poetry install --no-interaction --no-ansi
37+
# run pre-commit
38+
- uses: pre-commit/action@v3.0.1
39+
id: pre_commit
40+
continue-on-error: true
41+
- name: Check for changes
42+
if: ${{ steps.pre_commit.outcome == 'failure' }}
43+
id: check_changes
44+
run: |
45+
if [[ -n "$(git status --porcelain)" ]]; then
46+
echo "changes_detected=true" >> "$GITHUB_ENV"
47+
else
48+
echo "changes_detected=false" >> "$GITHUB_ENV"
49+
fi
50+
- name: Commit and push changes
51+
if: ${{ env.changes_detected == 'true' &&
52+
steps.pre_commit.outcome == 'failure' }}
53+
run: |
54+
git config --global user.name "github-actions[bot]"
55+
git config --global user.email \
56+
"github-actions[bot]@users.noreply.github.com"
57+
git add .
58+
git commit -m "chore: auto-apply pre-commit fixes"
59+
git push
60+
# raise error if there were no changes and pre-commit failed
61+
- name: Errors detected
62+
if: ${{ env.changes_detected == 'false' &&
63+
steps.pre_commit.outcome == 'failure' }}
64+
run: |
65+
echo 'Pre-commit failed and was unable to make changes'
66+
exit 1

.github/workflows/run-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
jobs:
1212
pre_commit_checks:
1313
runs-on: ubuntu-24.04
14+
# we avoid running duplicative
15+
# pre-commit checks for dependabot PRs
16+
if: github.actor != 'dependabot[bot]'
1417
steps:
1518
# checks out the repo
1619
- uses: actions/checkout@v5

0 commit comments

Comments
 (0)