Skip to content

Commit

Permalink
feat(ci)!: deploymentconfig deprecation (#244)
Browse files Browse the repository at this point in the history
Co-authored-by: Derek Roberts <derek.roberts@gmail.com>
  • Loading branch information
paulushcgcj and DerekRoberts authored Oct 4, 2024
1 parent bdbcc5f commit ea6a0c4
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 170 deletions.
16 changes: 0 additions & 16 deletions .github/example_workflows/issue-todo.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/example_workflows/issue-triage.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/openshift.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ parameters:
true
- name: COMPONENT
description: Component name
value: backend
value: api
- name: DOMAIN
value: apps.silver.devops.gov.bc.ca
objects:
Expand Down
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/action-get-pr@v0.0.1

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/action-gwa-publish@v0.1.0
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/action-gwa-publish@v0.1.0
Expand Down
55 changes: 13 additions & 42 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,25 @@ name: Pull Request Close

on:
pull_request:
types:
- closed

env:
REGISTRY: ghcr.io
NAME: ${{ github.event.repository.name }}
types: [closed]

concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
# PR open and close use the same group, allowing only one at a time
group: ${{ github.event.number }}
cancel-in-progress: true

jobs:
# Clean up OpenShift when PR closed, no conditions
cleanup-openshift:
name: Cleanup OpenShift
runs-on: ubuntu-24.04
environment:
name: dev
steps:
- uses: actions/checkout@v4
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.13"

- name: Remove OpenShift artifacts
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
oc project ${{ secrets.OC_NAMESPACE }}
# Remove old build runs, build pods and deployment pods
oc delete all,pvc,secret -l app=${{ env.NAME }}-${{ github.event.number }}
# If merged into main, then handle any image promotions
image-promotions:
name: Image Promotions
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
runs-on: ubuntu-24.04
steps:
- name: Promoting API
uses: shrink/actions-docker-registry-tag@v4
with:
registry: ghcr.io
repository: ${{ github.repository }}/api
target: ${{ github.event.number }}
tags: test

cleanup:
name: Cleanup and Images
uses: bcgov/quickstart-openshift-helpers/.github/workflows/.pr-close.yml@v0.8.0
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
with:
cleanup: label
environment: dev
packages: api

# Notify when PR merged and branch = main
merge-notification:
name: Merge Notification
runs-on: ubuntu-24.04
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ jobs:
Thanks for the PR!
Any successful deployments (not always required) will be available below.
[API](https://${{ github.event.repository.name }}-${{ github.event.number }}-backend.${{ env.DOMAIN }}/) available
[API](https://${{ github.event.repository.name }}-${{ github.event.number }}-api.${{ env.DOMAIN }}/) available
Once merged, code will be promoted and handed off to following workflow run.
[Main Merge Workflow](https://github.com/${{ github.repository }}/actions/workflows/merge-main.yml)
build:
name: Build
runs-on: ubuntu-latest
Expand All @@ -97,16 +99,13 @@ jobs:
build_file: Dockerfile
build_args: |
APP_VERSION=${{ needs.pr-validation.outputs.semver }}-${{ github.event.number }}
deploy:
name: Deploy
needs: [build]
runs-on: ubuntu-24.04
timeout-minutes: 15
environment:
name: dev
environment: dev
steps:
- name: Deploys
uses: bcgov-nr/action-deployer-openshift@v3.0.1
Expand All @@ -126,6 +125,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/action-deployer-openshift@v3.0.1
Expand All @@ -142,8 +142,7 @@ jobs:
postman:
name: Smoke Test
needs: [deploy]
environment:
name: dev
environment: dev
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -156,15 +155,15 @@ jobs:
uses: matt-ball/newman-action@master
with:
collection: postman/FCA.postman_collection.json
envVar: '[{"key":"URL_FCA","value":"https://${{ github.event.repository.name }}-${{ github.event.number }}-backend.${{ env.DOMAIN }}"}]'
envVar: '[{"key":"URL_FCA","value":"https://${{ github.event.repository.name }}-${{ github.event.number }}-api.${{ env.DOMAIN }}"}]'
reporters: '["cli"]'
folder: '["general"]'

- name: Postman Smoke Test
uses: matt-ball/newman-action@master
with:
collection: postman/FCA.postman_collection.json
envVar: '[{"key":"URL_FCA","value":"https://${{ github.event.repository.name }}-${{ github.event.number }}-backend.${{ env.DOMAIN }}"}]'
envVar: '[{"key":"URL_FCA","value":"https://${{ github.event.repository.name }}-${{ github.event.number }}-api.${{ env.DOMAIN }}"}]'
iterationData: postman/FCA_postman_tests_dev.json
reporters: '["cli", "junit"]'
reporter: '{ "junit" : { "export" : "./postman/report.xml" } }'
Expand Down
Loading

0 comments on commit ea6a0c4

Please sign in to comment.