-
Notifications
You must be signed in to change notification settings - Fork 36
69 lines (66 loc) · 2.27 KB
/
style_fix.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Style-Fix
on:
issue_comment:
types: [created, edited]
jobs:
style_fix:
name: Style-Fix
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/format' }}
runs-on: ubuntu-24.04
steps:
- name: Get PR Info
id: pr-info
uses: actions/github-script@v7
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
})
core.setOutput('REPO', pr.data.head.repo.full_name);
core.setOutput('REF', pr.data.head.ref);
# Checkout master
- uses: actions/checkout@v4
with:
ref: master
path: master
token: ${{ secrets.PAT_MEGAMOLSERVICE }}
show-progress: false
# Checkout PR repo/branch
- uses: actions/checkout@v4
with:
repository: ${{ steps.pr-info.outputs.REPO }}
ref: ${{ steps.pr-info.outputs.REF }}
path: pr
token: ${{ secrets.PAT_MEGAMOLSERVICE }}
show-progress: false
- name: Install clang-format
run: master/.ci/install-clang-format.sh
- name: Fix style
# WARNING: This job runs with repo permissions! Do not execute any code from PR branch!
run: |
# Run style fix with script from master branch
cd pr
../master/.ci/check_format.sh --fix
# Commit changes
if ! git diff --quiet --exit-code; then
git config user.email "[email protected]"
git config user.name "MegaMol-Bot"
git commit -am "Format fix."
git push
else
echo "Nothing to commit!"
fi
- name: Comment
if: ${{ failure() }}
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Formatting failed! For details, please check the [log](https://github.com/'
+ context.repo.owner + '/' + context.repo.repo + '/actions/runs/' + context.runId + ')!'
})