From 20676b6549ceba8ae50a16e27e1fb2574896690c Mon Sep 17 00:00:00 2001 From: GiampieroPorfiri Date: Wed, 11 Oct 2023 11:55:48 +0200 Subject: [PATCH] [NOD-530] feat: Semantic versioning, new GH Action add_patch_label, new java version tag --- .github/workflows/01_add_patch_label.yml | 60 ++++++++++++++++++++++++ .github/workflows/03_code_review.yml | 3 +- .github/workflows/04_release_deploy.yml | 2 +- 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/01_add_patch_label.yml diff --git a/.github/workflows/01_add_patch_label.yml b/.github/workflows/01_add_patch_label.yml new file mode 100644 index 0000000..00e0fc5 --- /dev/null +++ b/.github/workflows/01_add_patch_label.yml @@ -0,0 +1,60 @@ +name: Add PATCH default label + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + pull_request_target: + branches: + - main + types: [ opened, reopened ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + add_patch_label: + runs-on: ubuntu-latest + name: Add default label + steps: + - name: Check user labels + id: check_user_labels + uses: actions/github-script@v6.3.3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var addPatch = "true"; + // retrieve label list + let labels = await github.rest.issues.listLabelsOnIssue({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo + }); + + // verify if user have already added IGNORE-FOR-RELEASE, then skip add PATCH + // note: GitHub labels are added in .identity/03_github_environment.tf as github_issue_label resource + if (labels.data.find(label => label.name === 'ignore-for-release')){ + addPatch = "false"; + } + return addPatch; + result-encoding: string + + - name: Add PATCH label + if: ${{ steps.check_user_labels.outputs.result == 'true' }} + uses: pagopa/github-actions-template/default-label@main + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + label: 'patch' + + - name: Add comment + if: ${{ steps.check_user_labels.outputs.result == 'true' }} + uses: actions/github-script@v6.3.3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'The default action is to increase the `PATCH` number of `SEMVER`. Set `IGNORE-FOR-RELEASE` if you want to skip `SEMVER` bump. `BREAKING-CHANGE` and `NEW-RELEASE` must be run from GH Actions section manually.' + }); \ No newline at end of file diff --git a/.github/workflows/03_code_review.yml b/.github/workflows/03_code_review.yml index 6c7c646..8b7b9f2 100644 --- a/.github/workflows/03_code_review.yml +++ b/.github/workflows/03_code_review.yml @@ -35,13 +35,14 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Code Review - uses: pagopa/github-actions-template/maven-code-review@v1.4.1 + uses: pagopa/github-actions-template/maven-code-review@v1.8.3 with: github_token: ${{ secrets.GITHUB_TOKEN }} sonar_token: ${{ secrets.SONAR_TOKEN }} project_key: ${{env.PROJECT_KEY}} coverage_exclusions: "**/config/*,**/*Mock*,**/model/**,**/entity/*" cpd_exclusions: "**/model/**,**/entity/*" + java_version: '17' # smoke-test: # name: Smoke Test diff --git a/.github/workflows/04_release_deploy.yml b/.github/workflows/04_release_deploy.yml index 6234a74..4920b0f 100644 --- a/.github/workflows/04_release_deploy.yml +++ b/.github/workflows/04_release_deploy.yml @@ -60,7 +60,7 @@ jobs: steps: - name: Semver setup id: semver_setup - uses: pagopa/github-actions-template/node-semver-setup@a1b72480e9ac555364be0b7ecdcc8f5ab1c89ad9 + uses: pagopa/github-actions-template/nodo5-semver-setup@ce252c8501c9242bd6045f7cdd650736b2f38777 with: semver: ${{ inputs.semver }}