Skip to content

Merge

Merge #196

Workflow file for this run

name: Merge
on:
workflow_run:
workflows: [PR Closed]
types: [completed]
workflow_dispatch:
inputs:
pr_no:
description: "PR-numbered container set to deploy"
type: number
required: true
jobs:
vars:
name: PR Number and Semver
outputs:
tag: ${{ steps.tag.outputs.tag }}
runs-on: ubuntu-22.04
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
# Outputs semver as steps.id.outputs.tag
- name: Conventional Changelog Update
uses: TriPSs/conventional-changelog-action@v4
id: changelog
with:
git-branch: refs/heads/${{ github.event.repository.default_branch }}
git-push: "false"
github-token: ${{ github.token }}
skip-commit: "true"
skip-on-empty: "false"
skip-version-file: "true"
# Create and push semver tag
- name: Create Tags
run: |
git tag ${{ steps.changelog.outputs.tag }}
git push origin --tag
# Get last merged (or current) PR number
- name: Get PR Number
id: tag
run: |
# Accept a provided PR as input or use the API
if [ ! -z "${{ inputs.pr_no }}" ]; then
PR_NO="${{ inputs.pr_no }}"
else
HEAD=$(git log main --oneline | head -n1 | awk '{print $1}')
PR_NO=$(\
curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/bcgov/quickstart-openshift/commits/${HEAD}/pulls \
| jq .[0].number
)
fi
echo -e "Last PR: ${PR_NO}"
# Validate PR number and send to output
if [ "${PR_NO}" =~ ^[0-9]+$ ]; then
echo "No PR number not found"
exit 1
fi
echo "tag=${PR_NO}" >> $GITHUB_OUTPUT
deploy-prod:
name: Deploy (prod)
needs: [vars]
uses: ./.github/workflows/.deploy.yml
secrets: inherit
with:
directory: charts/quickstart-openshift
environment: prod
tag: ${{ needs.vars.outputs.tag }}
release: prod
promote:
name: Promote Images
needs: [deploy-prod, vars]
runs-on: ubuntu-22.04
permissions:
packages: write
strategy:
matrix:
package: [migrations, backend, frontend]
timeout-minutes: 1
steps:
- uses: shrink/actions-docker-registry-tag@v3
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: ${{ needs.vars.outputs.tag }}
tags: prod