Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix pipeline pr into test #538

Merged
merged 6 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/actions/get-pr-number.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/merge-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ../actions/get-pr-number

# https://github.com/bcgov/quickstart-openshift-helpers
deploy-test:
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading