Skip to content

Commit f2c8062

Browse files
committed
Add a workflow to run auto updates for pre-commit
This replaces the pre-commit.ci app's autoupdate. The one caveat with this is that it doesn't check for PRs that are already opened on that branch. I did that to keep it as simple as possible. It's not a real issue as github will detect that and close the previous PR and then open a new one but it might be a bit spammy if we don't merge those PRs
1 parent f85ff32 commit f2c8062

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Autoupdate
2+
on:
3+
schedule:
4+
- cron: '0 0 1 * *'
5+
jobs:
6+
pre-commit:
7+
name: Pre-commit
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup git
15+
run: |
16+
git config --global user.name "Pre-commit automation"
17+
git config --global user.email "releng+pre-commit-autoupdate@mozilla.com"
18+
- uses: actions/setup-python@v5
19+
- run: python -m pip install pre-commit
20+
shell: bash
21+
- name: Update files
22+
run: |
23+
git checkout -B pre-commit-update
24+
pre-commit autoupdate -j4
25+
git add .pre-commit-config.yaml
26+
git commit -am "Update pre-commit"
27+
git push -f origin pre-commit-update
28+
- name: Create PR if necessary
29+
run: |
30+
curl -sL \
31+
-X POST \
32+
-H "Accept: application/vnd.github+json" \
33+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
34+
-H "X-GitHub-Api-Version: 2022-11-28" \
35+
https://api.github.com/repos${{ github.reository_owner }}/${{ github.repository }}/pulls \
36+
-d '{"title":"Update pre-commit","body":"","head":"pre-commit-update","base":"${{ github.event.repository.default_branch }}"}'

0 commit comments

Comments
 (0)