-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from bcgov/feature/frontend
Action workflows using quickstart openshift / frontend initial commit
- Loading branch information
Showing
765 changed files
with
33,130 additions
and
16,777 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
name: .Helm Deployer | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
### Required | ||
# Only secrets! | ||
|
||
### Typical / recommended | ||
atomic: | ||
description: Atomic deployment? That means fail all or nothing | ||
default: true | ||
required: false | ||
type: string | ||
directory: | ||
description: Chart directory | ||
default: 'charts/app' | ||
required: false | ||
type: string | ||
environment: | ||
description: Environment name; omit for PRs | ||
required: false | ||
type: string | ||
oc_server: | ||
default: https://api.silver.devops.gov.bc.ca:6443 | ||
description: 'OpenShift server' | ||
required: false | ||
type: string | ||
params: | ||
description: 'Extra parameters to pass to helm upgrade' | ||
default: '' | ||
required: false | ||
type: string | ||
tag: | ||
description: Specify a tag to deploy; defaults to PR number | ||
required: false | ||
type: string | ||
triggers: | ||
description: Paths used to trigger a deployment; e.g. ('./backend/' './frontend/) | ||
required: false | ||
type: string | ||
|
||
### Usually a bad idea / not recommended | ||
timeout-minutes: | ||
description: 'Timeout minutes' | ||
default: 10 | ||
required: false | ||
type: number | ||
values: | ||
description: 'Values file' | ||
default: 'values.yaml' | ||
required: false | ||
type: string | ||
|
||
outputs: | ||
triggered: | ||
description: 'Has a deployment has been triggered?' | ||
value: ${{ jobs.deployer.outputs.triggered }} | ||
|
||
secrets: | ||
oc_namespace: | ||
description: OpenShift namespace | ||
required: true | ||
oc_token: | ||
description: OpenShift token | ||
required: true | ||
|
||
jobs: | ||
deployer: | ||
name: Helm | ||
environment: ${{ inputs.environment }} | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
triggered: ${{ steps.triggers.outputs.triggered }} | ||
steps: | ||
### Triggers, tag and release | ||
|
||
# Check triggers (omitted or matched) for deployment | ||
- uses: bcgov-nr/[email protected] | ||
id: triggers | ||
with: | ||
triggers: ${{ inputs.triggers }} | ||
|
||
# Variables | ||
- if: steps.triggers.outputs.triggered == 'true' | ||
id: pr | ||
uses: bcgov-nr/[email protected] | ||
- if: steps.triggers.outputs.triggered == 'true' | ||
id: vars | ||
run: | | ||
# Vars: tag and release | ||
# Tag defaults to PR number, but can be overridden by inputs.tag | ||
tag=${{ inputs.tag || steps.pr.outputs.pr }} | ||
# Release name includes run numbers to ensure uniqueness | ||
release=${{ github.event.repository.name }}-${{ inputs.environment || steps.pr.outputs.pr }} | ||
# Summary | ||
echo "tag=${tag}" | ||
echo "release=${release}" | ||
# Output | ||
echo "tag=${tag}" >> $GITHUB_OUTPUT | ||
echo "release=${release}" >> $GITHUB_OUTPUT | ||
### Deploy | ||
|
||
# OC Login | ||
- if: steps.triggers.outputs.triggered == 'true' | ||
run: | | ||
# OC Login | ||
oc login --token=${{ secrets.oc_token }} --server=${{ inputs.oc_server }} | ||
oc project ${{ secrets.oc_namespace }} # Safeguard! | ||
# Only stop pre-existing deployments on PRs (status = pending-upgrade) | ||
- if: steps.triggers.outputs.triggered == 'true' && github.event_name == 'pull_request' | ||
run: | | ||
# Interrupt any previous deployments (PR only) | ||
PREVIOUS=$(helm status ${{ steps.vars.outputs.release }} -o json | jq .info.status || true) | ||
if [[ ${PREVIOUS} =~ pending ]]; then | ||
echo "Rollback triggered" | ||
helm rollback ${{ steps.vars.outputs.release }} || \ | ||
helm uninstall ${{ steps.vars.outputs.release }} | ||
fi | ||
# Package Helm chart | ||
- if: steps.triggers.outputs.triggered == 'true' | ||
uses: actions/checkout@v4 | ||
- if: steps.triggers.outputs.triggered == 'true' | ||
working-directory: ${{ inputs.directory }} | ||
run: | | ||
# Helm package | ||
sed -i 's/^name:.*/name: ${{ github.event.repository.name }}/' Chart.yaml | ||
helm package -u . --app-version="tag-${{ steps.vars.outputs.tag }}_run-${{ github.run_number }}" --version=${{ steps.pr.outputs.pr }} | ||
# Deploy Helm chart as atomic, with timeout | ||
- if: steps.triggers.outputs.triggered == 'true' && inputs.atomic != 'false' | ||
working-directory: ${{ inputs.directory }} | ||
run: | | ||
# Helm upgrade/rollout - atomic, timeout | ||
helm upgrade \ | ||
--set-string global.repository=${{ github.repository }} \ | ||
--set-string global.tag=${{ steps.vars.outputs.tag }} \ | ||
--set frontend.env.VITE_SSO_AUTH_SERVER_URL=${{ secrets.VITE_SSO_AUTH_SERVER_URL }} \ | ||
--set frontend.env.VITE_SSO_CLIENT_ID=${{ secrets.VITE_SSO_CLIENT_ID }} \ | ||
--set frontend.env.VITE_SSO_REALM=${{ secrets.VITE_SSO_REALM }} \ | ||
--set frontend.env.VITE_SSO_REDIRECT_URI=${{ secrets.VITE_SSO_REDIRECT_URI }} \ | ||
${{ inputs.params }} \ | ||
--install --wait --atomic ${{ steps.vars.outputs.release }} \ | ||
--timeout ${{ inputs.timeout-minutes }}m \ | ||
--values ${{ inputs.values }} \ | ||
./${{ github.event.repository.name }}-${{ steps.pr.outputs.pr }}.tgz | ||
# Deploy Helm chart without atomic or timeout | ||
- if: steps.triggers.outputs.triggered == 'true' && inputs.atomic == 'false' | ||
working-directory: ${{ inputs.directory }} | ||
run: | | ||
# Helm upgrade/rollout - non-atomic, no timeout | ||
helm upgrade \ | ||
--set-string global.repository=${{ github.repository }} \ | ||
--set-string global.tag=${{ steps.vars.outputs.tag }} \ | ||
${{ inputs.params }} \ | ||
${{ steps.vars.outputs.release }} \ | ||
--install --wait --values ${{ inputs.values }} \ | ||
./${{ github.event.repository.name }}-${{ steps.pr.outputs.pr }}.tgz | ||
# Helm release history | ||
- if: steps.triggers.outputs.triggered == 'true' | ||
run: | | ||
# Helm release history | ||
helm history ${{ steps.vars.outputs.release }} | ||
### Cleanup | ||
|
||
# Completed pod cleanup | ||
- if: steps.triggers.outputs.triggered == 'true' | ||
run: | | ||
# Completed pod cleanup | ||
oc delete po --field-selector=status.phase==Succeeded || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Build and Deploy to Openshift Dev | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- "frontend/**" | ||
- "backend/**" | ||
concurrency: | ||
# Cancel if re-attempted | ||
group: ${{ github.event_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
# https://github.com/bcgov-nr/action-builder-ghcr | ||
builds: | ||
name: Builds | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
package: [backend, frontend] | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: bcgov-nr/[email protected] | ||
with: | ||
package: ${{ matrix.package }} | ||
tag: ${{ github.event.number }} | ||
tag_fallback: latest | ||
triggers: ('${{ matrix.package }}/') | ||
|
||
# https://github.com/bcgov/quickstart-openshift-helpers | ||
deploys: | ||
name: Deploys | ||
needs: [builds] | ||
uses: ./.github/workflows/.deployer.yml | ||
secrets: | ||
inherit | ||
# oc_namespace: ${{ secrets.OC_NAMESPACE }} | ||
# oc_token: ${{ secrets.OC_TOKEN }} | ||
with: | ||
environment: dev | ||
values: "values-dev.yaml" | ||
triggers: ('backend/' 'frontend/') | ||
params: | | ||
--set global.secrets.persist=false \ | ||
# tests: | ||
# name: Tests | ||
# if: needs.deploys.outputs.triggered == 'true' | ||
# needs: [deploys] | ||
# uses: ./.github/workflows/.tests.yml | ||
# with: | ||
# target: ${{ github.event.number }} | ||
|
||
results: | ||
name: PR Results | ||
needs: [builds, deploys] | ||
if: always() && (!failure()) && (!cancelled()) | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- run: echo "Success!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Build and Deploy to Openshift Test | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
# Cancel if re-attempted | ||
group: ${{ github.event_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
# https://github.com/bcgov-nr/action-builder-ghcr | ||
builds: | ||
name: Builds | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
package: [backend, frontend] | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: bcgov-nr/[email protected] | ||
with: | ||
keep_versions: 50 | ||
package: ${{ matrix.package }} | ||
tag: ${{ github.event.number }} | ||
tag_fallback: latest | ||
triggers: ('${{ matrix.package }}/') | ||
|
||
# https://github.com/bcgov/quickstart-openshift-helpers | ||
deploys: | ||
name: Deploys | ||
needs: [builds] | ||
uses: bcgov/quickstart-openshift-helpers/.github/workflows/[email protected] | ||
secrets: | ||
oc_namespace: ${{ secrets.OC_NAMESPACE }} | ||
oc_token: ${{ secrets.OC_TOKEN }} | ||
with: | ||
environment: test | ||
values: "values-test.yaml" | ||
triggers: ('backend/' 'frontend/') | ||
params: --set global.secrets.persist=false | ||
|
||
# tests: | ||
# name: Tests | ||
# if: needs.deploys.outputs.triggered == 'true' | ||
# needs: [deploys] | ||
# uses: ./.github/workflows/.tests.yml | ||
# with: | ||
# target: ${{ github.event.number }} | ||
|
||
results: | ||
name: PR Results | ||
needs: [builds, deploys] | ||
if: always() && (!failure()) && (!cancelled()) | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- run: echo "Success!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
target/** | ||
.dockerignore | ||
.gitignore | ||
Dockerfile | ||
mvnw.cmd | ||
*.yml | ||
*.yaml | ||
*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#Maven | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
release.properties | ||
.flattened-pom.xml | ||
|
||
# Eclipse | ||
.project | ||
.classpath | ||
.settings/ | ||
bin/ | ||
|
||
# IntelliJ | ||
.idea | ||
*.ipr | ||
*.iml | ||
*.iws | ||
|
||
# NetBeans | ||
nb-configuration.xml | ||
|
||
# Visual Studio Code | ||
.vscode | ||
.factorypath | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# Vim | ||
*.swp | ||
*.swo | ||
|
||
# patch | ||
*.orig | ||
*.rej | ||
|
||
# Local environment | ||
.env | ||
|
||
# Plugin directory | ||
/.quarkus/cli/plugins/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
maven-wrapper.jar |
Oops, something went wrong.