Skip to content

Commit 4dff397

Browse files
authored
CI: add slash dispatch workflow to trigger pre-commit checks with comment (#38444)
1 parent e067fe6 commit 4dff397

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

.github/workflows/autoupdate-pre-commit-config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Update pre-commit config packages
2424
uses: technote-space/create-pr-action@v2
2525
with:
26-
GITHUB_TOKEN: ${{ secrets.ACTION_TRIGGER_TOKEN }}
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2727
EXECUTE_COMMANDS: |
2828
pip install pre-commit
2929
pre-commit autoupdate || (exit 0);

.github/workflows/comment_bot.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Comment-bot
2+
3+
on:
4+
issue_comment:
5+
types:
6+
- created
7+
- edited
8+
9+
jobs:
10+
autotune:
11+
name: "Fixup pre-commit formatting"
12+
if: startsWith(github.event.comment.body, '@github-actions pre-commit')
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: r-lib/actions/pr-fetch@master
17+
with:
18+
repo-token: ${{ secrets.GITHUB_TOKEN }}
19+
- name: Cache multiple paths
20+
uses: actions/cache@v2
21+
with:
22+
path: |
23+
~/.cache/pre-commit
24+
~/.cache/pip
25+
key: pre-commit-dispatched-${{ runner.os }}-build
26+
- uses: actions/setup-python@v2
27+
with:
28+
python-version: 3.8
29+
- name: Install-pre-commit
30+
run: python -m pip install --upgrade pre-commit
31+
- name: Run pre-commit
32+
run: pre-commit run --all-files || (exit 0)
33+
- name: Commit results
34+
run: |
35+
git config user.name "$(git log -1 --pretty=format:%an)"
36+
git config user.email "$(git log -1 --pretty=format:%ae)"
37+
git commit -a -m 'Fixes from pre-commit [automated commit]' || echo "No changes to commit"
38+
- uses: r-lib/actions/pr-push@master
39+
with:
40+
repo-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)