Skip to content

Commit

Permalink
chore(ci): updating workflow to use pr number
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Oct 3, 2024
1 parent 3d051ce commit c716f60
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 48 deletions.
65 changes: 19 additions & 46 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ on:
push:
branches: [main]
paths-ignore:
- "**.md"
workflow_dispatch:
- '*.md'
- '.github/**'
- '.github/graphics/**'
- '.github/ISSUE_TEMPLATE/**'
- '!.github/workflows/**'

env:
DOMAIN: apps.silver.devops.gov.bc.ca
Expand All @@ -16,8 +19,19 @@ concurrency:
cancel-in-progress: true

jobs:
init:
name: Initialize
outputs:
pr: ${{ steps.pr.outputs.pr }}
runs-on: ubuntu-24.04
steps:
# Get PR number for squash merges to main
- id: pr
uses: bcgov-nr/[email protected]

deploy-test:
name: TEST Deployment
needs: [init]
runs-on: ubuntu-24.04
outputs:
tag: ${{ steps.changelog.outputs.tag }}
Expand Down Expand Up @@ -46,6 +60,7 @@ jobs:
-p ORACLEDB_SERVICENAME=${{ secrets.ORACLEDB_SERVICENAME }}
-p ORACLEDB_SECRET=${{ secrets.ORACLEDB_SECRET }}
-p ZONE=test
-p TAG=${{ needs.init.outputs.pr }}

- name: Publish API
uses: bcgov-nr/[email protected]
Expand All @@ -63,52 +78,9 @@ jobs:
reporters: '["cli"]'
folder: '["general"]'

- name: Conventional Changelog Update
uses: TriPSs/conventional-changelog-action@v5
id: changelog
continue-on-error: true
with:
github-token: ${{ github.token }}
output-file: "CHANGELOG.md"
skip-version-file: "true"
skip-commit: "true"
git-push: "true"

- name: Create Release
uses: softprops/action-gh-release@v2
if: ${{ steps.changelog.outputs.tag != '' }}
env:
GITHUB_TOKEN: ${{ github.token }}
with:
token: ${{ github.token }}
tag_name: ${{ steps.changelog.outputs.tag }}
name: ${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.clean_changelog }}

image-promotions:
name: Image Promotions
needs: [deploy-test]
runs-on: ubuntu-24.04
strategy:
matrix:
tag: [prod, "${{ needs.deploy-test.outputs.tag }}"]
steps:
- name: Promoting API
if: ${{ matrix.tag != '' }}
uses: shrink/actions-docker-registry-tag@v4
with:
registry: ghcr.io
repository: ${{ github.repository }}/api
target: test
tags: ${{ matrix.tag }}

- name: Promoting API
if: ${{ matrix.tag == '' }}
run: echo "Tag is empty, promotion step skipped"

deploy-prod:
name: PROD Deployment
needs: [image-promotions]
needs: [deploy-test, init]
runs-on: ubuntu-24.04
environment:
name: prod
Expand All @@ -133,6 +105,7 @@ jobs:
-p ORACLEDB_SERVICENAME=${{ secrets.ORACLEDB_SERVICENAME }}
-p ORACLEDB_SECRET=${{ secrets.ORACLEDB_SECRET }}
-p ZONE=prod
-p TAG=${{ needs.init.outputs.pr }}

- name: Publish API
uses: bcgov-nr/[email protected]
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
Expand All @@ -99,7 +100,6 @@ jobs:
build_args: |
APP_VERSION=${{ needs.pr-validation.outputs.semver }}-${{ github.event.number }}
deploy:
name: Deploy
needs: [build]
Expand All @@ -126,6 +126,7 @@ jobs:
-p ORACLEDB_SERVICENAME=${{ secrets.ORACLEDB_SERVICENAME }}
-p ORACLEDB_SECRET=${{ secrets.ORACLEDB_SECRET }}
-p ZONE=${{ github.event.number }}
-p TAG=${{ github.event.number }}

- name: Deploy dev route
uses: bcgov-nr/[email protected]
Expand All @@ -138,6 +139,7 @@ jobs:
overwrite: true
parameters:
-p ZONE=${{ github.event.number }}
-p TAG=${{ github.event.number }}

postman:
name: Smoke Test
Expand Down
5 changes: 4 additions & 1 deletion openshift.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ parameters:
- name: ZONE
description: Deployment zone, e.g. pr-### or prod
required: true
- name: TAG
description: The image tag to deploy
required: true
- name: REGISTRY
description: Container registry to import from (internal is image-registry.openshift-image-registry.svc:5000)
value: ghcr.io
Expand Down Expand Up @@ -138,7 +141,7 @@ objects:
cpu: ${CPU_REQUEST}
memory: ${MEMORY_REQUEST}
containers:
- image: ${REGISTRY}/${ORG}/${NAME}/${COMPONENT}:${ZONE}
- image: ${REGISTRY}/${ORG}/${NAME}/${COMPONENT}:${TAG}
imagePullPolicy: Always
name: ${NAME}
env:
Expand Down

0 comments on commit c716f60

Please sign in to comment.