Update Code #854
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v3 | |
with: | |
ref: ${{ github.ref }} | |
token: ${{ secrets.BOT_TOKEN_GITHUB }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 17 | |
# - name: Update OpenApi/Swagger file | |
# run: | | |
# cd ./docker | |
# chmod +x ./run_docker.sh | |
# ./run_docker.sh local | |
# | |
# 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 [skip ci]" | |
git push | |
notify: | |
needs: [ update ] | |
runs-on: ubuntu-latest | |
name: Notify | |
if: ${{ always() && contains(needs.*.result, 'failure') }} | |
steps: | |
- name: Notify if Failure | |
uses: actions/[email protected] | |
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.') |