Update Code #1641
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@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 | |
with: | |
token: ${{ secrets.BOT_TOKEN_GITHUB }} | |
- name: Get PR details | |
id: get_pr | |
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const pr_number = "${{ github.event.inputs.pr_number }}"; | |
const pr = await github.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: pr_number | |
}); | |
return pr.data.head.ref; | |
- name: Checkout PR branch | |
run: | | |
git fetch origin ${{ steps.get_pr.outputs.result }} | |
git checkout ${{ steps.get_pr.outputs.result }} | |
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 "pagopa-github-bot@pagopa.it" | |
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: | | |
const script = require('./.github/workflows/github_scripts/update_code.js') | |
await script({github, context, core}) |