From f49a974058b7c3c5b651165313da77f6b9d7294a Mon Sep 17 00:00:00 2001 From: barrfalk Date: Thu, 18 Jul 2024 16:02:49 -0700 Subject: [PATCH 1/5] Added new github action to retrieve the PR associated with the branch to be merged into the release branch --- .github/workflows/get-pr-number.yml | 56 +++++++++++++++++++++++++++++ .github/workflows/merge-release.yml | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/get-pr-number.yml diff --git a/.github/workflows/get-pr-number.yml b/.github/workflows/get-pr-number.yml new file mode 100644 index 000000000..9bce399b6 --- /dev/null +++ b/.github/workflows/get-pr-number.yml @@ -0,0 +1,56 @@ +name: Get PR Number +description: Get PR number for merge queues and squash merges +branding: + icon: package + color: blue + +inputs: + token: + description: Specify token (GH or PAT), instead of inheriting one from the calling workflow + default: ${{ github.token }} + +outputs: + pr: + description: "Associated pull request number" + value: ${{ steps.vars.outputs.pr }} + +runs: + using: composite + steps: + - id: vars + shell: bash + run: | + # Get PR number based on the event type + if [ "${{ github.event_name }}" == 'pull_request' ]; then + echo "Event type: pull request" + pr=${{ github.event.number }} + elif [ "${{ github.event_name }}" == 'merge_group' ]; then + echo "Event type: merge queue" + pr=$(echo ${{ github.event.merge_group.head_ref }} | grep -Eo "queue/main/pr-[0-9]+" | cut -d '-' -f2) + elif [ "${{ github.event_name }}" == 'push' ]; then + echo "Event type: push" + pr=$(\ + curl -sL -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ inputs.token }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls \ + | jq 'map(select(.base.ref == "release/${{ github.ref_name }}")) | .[0].number' + ) + if [ -z "${pr}" ]; then + echo "No PR number found. Was this push triggered by a squashed PR merge?" + pr="" + fi + else + echo "Event type: unknown or unexpected" + pr="" + fi + + # Validate PR number + if [[ ! "${pr}" =~ ^[0-9]+$ ]]; then + echo "PR number format incorrect: ${pr}" + exit 1 + fi + + # Output PR number + echo "Summary ---" + echo -e "\tPR: ${pr}" + echo "pr=${pr}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/merge-release.yml b/.github/workflows/merge-release.yml index f4a99ddd6..0c4d325d9 100644 --- a/.github/workflows/merge-release.yml +++ b/.github/workflows/merge-release.yml @@ -31,7 +31,7 @@ jobs: # Get PR number for squash merges to release - name: PR Number id: pr - uses: bcgov-nr/action-get-pr@v0.0.1 + uses: ./get-pr-number.yml # https://github.com/bcgov/quickstart-openshift-helpers deploy-test: From ddb816772746783e21f843c500dff77ab14ee345 Mon Sep 17 00:00:00 2001 From: barrfalk Date: Thu, 18 Jul 2024 16:09:53 -0700 Subject: [PATCH 2/5] Corrected location of new action --- .github/{workflows => actions}/get-pr-number.yml | 0 .github/workflows/merge-release.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/{workflows => actions}/get-pr-number.yml (100%) diff --git a/.github/workflows/get-pr-number.yml b/.github/actions/get-pr-number.yml similarity index 100% rename from .github/workflows/get-pr-number.yml rename to .github/actions/get-pr-number.yml diff --git a/.github/workflows/merge-release.yml b/.github/workflows/merge-release.yml index 0c4d325d9..69478f4b5 100644 --- a/.github/workflows/merge-release.yml +++ b/.github/workflows/merge-release.yml @@ -31,7 +31,7 @@ jobs: # Get PR number for squash merges to release - name: PR Number id: pr - uses: ./get-pr-number.yml + uses: ../actions/get-pr-number # https://github.com/bcgov/quickstart-openshift-helpers deploy-test: From 602dbcfa38ea8f5cdbe89ca6d6b9bcf5dda4b615 Mon Sep 17 00:00:00 2001 From: barrfalk Date: Thu, 18 Jul 2024 16:24:57 -0700 Subject: [PATCH 3/5] Update main.ts --- backend/src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main.ts b/backend/src/main.ts index a7bd274d3..8b5688a66 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -19,7 +19,7 @@ async function bootstrap() { process.env.TZ = "UTC"; const config = new DocumentBuilder() .setTitle("NatComplaints - Complaint Management API") - .setDescription("The Complicance and Enforcement - Complaint Management API") + .setDescription("NatComplaints - Complaint Management API") .setVersion("1.0") .addTag("Compliance and Enforcement - Complaint Management") .build(); From f13d58798ce0e48c4438f5e3c2f4d51aa8038bea Mon Sep 17 00:00:00 2001 From: barrfalk Date: Thu, 18 Jul 2024 16:27:12 -0700 Subject: [PATCH 4/5] Update merge-release.yml --- .github/workflows/merge-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/merge-release.yml b/.github/workflows/merge-release.yml index 69478f4b5..49d7471bf 100644 --- a/.github/workflows/merge-release.yml +++ b/.github/workflows/merge-release.yml @@ -31,7 +31,7 @@ jobs: # Get PR number for squash merges to release - name: PR Number id: pr - uses: ../actions/get-pr-number + uses: ./.github/actions/get-pr-number # https://github.com/bcgov/quickstart-openshift-helpers deploy-test: From 03bfd1e93f4762a20b12c4665fbe87caed8f764f Mon Sep 17 00:00:00 2001 From: barrfalk Date: Thu, 18 Jul 2024 16:27:55 -0700 Subject: [PATCH 5/5] Update main.ts --- backend/src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main.ts b/backend/src/main.ts index 8b5688a66..30ea5e6ad 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -21,7 +21,7 @@ async function bootstrap() { .setTitle("NatComplaints - Complaint Management API") .setDescription("NatComplaints - Complaint Management API") .setVersion("1.0") - .addTag("Compliance and Enforcement - Complaint Management") + .addTag("NatComplaints - Complaint Management") .build(); const document = SwaggerModule.createDocument(app, config);