generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: HELM deployment support. (#102)
- Loading branch information
Showing
50 changed files
with
1,606 additions
and
758 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,113 @@ | ||
name: .Deploys | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
### Required | ||
release: | ||
description: Deployment release; usually PR number, test or prod | ||
required: true | ||
type: string | ||
|
||
### Typical / recommended | ||
autoscaling: | ||
description: Autoscaling enabled or not for the deployments | ||
required: false | ||
type: string | ||
default: false | ||
build_outputs: | ||
description: Build outputs | ||
required: false | ||
type: string | ||
default: 'true' | ||
environment: | ||
description: Environment name; omit for PRs | ||
required: false | ||
type: string | ||
tag: | ||
description: Container tag; usually PR number | ||
required: false | ||
type: string | ||
default: ${{ github.event.number }} | ||
test: | ||
description: Run tests after deployment? | ||
required: false | ||
type: string | ||
default: "true" | ||
|
||
### Usually a bad idea / not recommended | ||
directory: | ||
description: 'Chart directory' | ||
default: 'charts/${{ github.event.repository.name }}' | ||
required: false | ||
type: string | ||
timeout-minutes: | ||
description: 'Timeout minutes' | ||
default: 10 | ||
required: false | ||
type: number | ||
values: | ||
description: 'Values file' | ||
default: 'values.yaml' | ||
required: false | ||
type: string | ||
params: | ||
description: 'Extra parameters to pass to helm upgrade' | ||
default: '' | ||
required: false | ||
type: string | ||
|
||
env: | ||
repo_release: ${{ github.event.repository.name }}-${{ inputs.release }} | ||
package_tag: ${{ inputs.tag }} | ||
|
||
jobs: | ||
deploys: | ||
name: Helm | ||
if: ${{ inputs.build_outputs != '' }} | ||
environment: ${{ inputs.environment }} | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: ${{ inputs.timeout-minutes }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Deploy | ||
working-directory: ${{ inputs.directory }} | ||
shell: bash | ||
run: | | ||
oc login --token=${{ secrets.oc_token }} --server=${{ vars.oc_server }} | ||
oc project ${{ vars.OC_NAMESPACE }} # Safeguard! | ||
# Interrupt any previous jobs (status = pending-upgrade) | ||
PREVIOUS=$(helm status ${{ env.repo_release }} -o json | jq .info.status || true) | ||
if [[ ${PREVIOUS} =~ pending ]]; then | ||
echo "Rollback triggered" | ||
helm rollback ${{ env.repo_release }} || \ | ||
helm uninstall ${{ env.repo_release }} | ||
fi | ||
# Clean previous deployments for PR pipeline, if any | ||
if [[ '${{inputs.environment}}' == '' ]]; then | ||
helm uninstall ${{ env.repo_release }} || true | ||
# Remove Bitnami Postgres PVCs | ||
oc delete pvc data-${{ env.repo_release }}-bitnami-pg-0 || \ | ||
echo "Not found: pvc data-${{ env.repo_release }}-bitnami-pg-0" | ||
fi | ||
# Deploy Helm Chart | ||
helm dependency update | ||
helm package --app-version="${{ env.package_tag }}" --version=${{ inputs.tag }} . | ||
helm upgrade \ | ||
--set global.autoscaling=${{ inputs.autoscaling }} \ | ||
--set-string global.repository=${{ github.repository }} \ | ||
--set-string global.tag=${{ inputs.tag }} \ | ||
${{ inputs.params }} \ | ||
--install --wait --atomic ${{ env.repo_release }} \ | ||
--timeout ${{ inputs.timeout-minutes }}m \ | ||
--values ${{ inputs.values }} \ | ||
./${{ github.event.repository.name }}-${{ inputs.tag }}.tgz | ||
# print history | ||
helm history ${{ env.repo_release }} | ||
# Remove old build runs, build pods and deployment pods | ||
oc delete po --field-selector=status.phase==Succeeded | ||
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
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
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
Oops, something went wrong.