From 00068c0d69f960df2c44d11d3a9bdd1f389f2d87 Mon Sep 17 00:00:00 2001 From: GiampieroPorfiri Date: Wed, 11 Oct 2023 14:48: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 | 4 +- .github/workflows/04_release_deploy.yml | 2 +- 3 files changed, 63 insertions(+), 3 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 5c4ccf5..1c8d866 100644 --- a/.github/workflows/03_code_review.yml +++ b/.github/workflows/03_code_review.yml @@ -30,7 +30,7 @@ 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@50aaf5cffa09d76b953e64a630bc9e0528a6d73b + uses: pagopa/github-actions-template/maven-code-review@v1.8.3 with: github_token: ${{ secrets.GITHUB_TOKEN }} sonar_token: ${{ secrets.SONAR_TOKEN }} @@ -38,4 +38,4 @@ jobs: coverage_exclusions: "**/config/*,**/*Mock*,**/models/**,**/entities/*" cpd_exclusions: "**/models/**,**/entities/*" java_distribution: "graalvm" - java_version: "17.0.7" + java_version: '17' diff --git a/.github/workflows/04_release_deploy.yml b/.github/workflows/04_release_deploy.yml index 6942d6c..3bc03d1 100644 --- a/.github/workflows/04_release_deploy.yml +++ b/.github/workflows/04_release_deploy.yml @@ -69,7 +69,7 @@ jobs: steps: - name: Semver setup id: semver_setup - uses: pagopa/github-actions-template/nodo5-semver-setup@de4ca1ddefb1461c176cc42259e494158b578fe3 + uses: pagopa/github-actions-template/nodo5-semver-setup@ce252c8501c9242bd6045f7cdd650736b2f38777 with: semver: ${{ inputs.semver }}