generated from pagopa/template-java-spring-microservice
-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (76 loc) · 2.57 KB
/
update_code.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Update Code
on:
issue_comment:
types: [created, edited]
permissions:
contents: write
pull-requests: write
issues: write
jobs:
update:
name: Update Openapi and Formatting
runs-on: ubuntu-latest
if: ${{ contains(github.event.comment.body, 'update_code') }}
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
token: ${{ secrets.BOT_TOKEN_GITHUB }}
- name: Checkout Pull Request
run: hub pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK 11
uses: actions/setup-java@b6e674f4b717d7b0ae3baee0fbe79f498905dfde # v1
with:
java-version: 11
- name: Update OpenApi/Swagger file
run: |
cd ./openapi
chmod +x ./generate_openapi.sh
./generate_openapi.sh
- name: Formatting
id: format
uses: findologic/intellij-format-action@main
with:
path: .
fail-on-changes: false
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "pagopa-github-bot"
git commit -a -m "Formatting"
git push
notify:
needs: [ update ]
runs-on: ubuntu-latest
name: Notify
if: ${{ always() && contains(needs.*.result, 'failure') }}
steps:
- name: Notify if Failure
uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
for (const comment of comments.data) {
if (comment.body.includes('Update Code is failed. Please retry.')){
github.rest.issues.deleteComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id
})
}
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Update Code is failed. Please retry.'
})
core.setFailed('Update Code is failed. Please retry.')