-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4962b7c
commit 3e6a7d6
Showing
2 changed files
with
95 additions
and
122 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 |
---|---|---|
|
@@ -72,73 +72,72 @@ on: | |
required: true | ||
|
||
jobs: | ||
# deployer-db: | ||
# name: Database | ||
# uses: ./.github/workflows/.deployer-db.yml | ||
# secrets: | ||
# oc_namespace: ${{ secrets.OC_NAMESPACE }} | ||
# oc_token: ${{ secrets.OC_TOKEN }} | ||
# with: | ||
# environment: ${{ inputs.environment }} | ||
# triggers: ${{ inputs.triggers }} | ||
deployer-db: | ||
name: Database | ||
uses: ./.github/workflows/.deployer-db.yml | ||
secrets: | ||
oc_namespace: ${{ secrets.OC_NAMESPACE }} | ||
oc_token: ${{ secrets.OC_TOKEN }} | ||
with: | ||
environment: ${{ inputs.environment }} | ||
triggers: ${{ inputs.triggers }} | ||
|
||
deploy: | ||
name: Stack | ||
# needs: deployer-db | ||
needs: deployer-db | ||
environment: ${{ inputs.environment }} | ||
runs-on: ubuntu-24.04 | ||
outputs: | ||
tag: ${{ inputs.tag || steps.pr.outputs.pr }} | ||
triggered: ${{ steps.deploy.outputs.triggered }} | ||
blerf: "blorf" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# Variables | ||
# - if: inputs.tag == '' | ||
# id: pr | ||
# uses: bcgov/[email protected] | ||
Variables | ||
- if: inputs.tag == '' | ||
id: pr | ||
uses: bcgov/[email protected] | ||
|
||
# - id: vars | ||
# run: | | ||
# # Vars: tag and release | ||
- 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 }} | ||
# 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 || inputs.tag }} | ||
# Release name includes run numbers to ensure uniqueness | ||
release=${{ github.event.repository.name }}-${{ inputs.environment || steps.pr.outputs.pr || inputs.tag }} | ||
# # version, to support helm packaging for non-pr based releases (workflow_dispatch). default to 1.0.0+github run number | ||
# version=1.0.0+${{ github.run_number }} | ||
# version, to support helm packaging for non-pr based releases (workflow_dispatch). default to 1.0.0+github run number | ||
version=1.0.0+${{ github.run_number }} | ||
# # Summary | ||
# echo "tag=${tag}" | ||
# echo "release=${release}" | ||
# echo "version=${version}" | ||
# Summary | ||
echo "tag=${tag}" | ||
echo "release=${release}" | ||
echo "version=${version}" | ||
# # Output | ||
# echo "tag=${tag}" >> $GITHUB_OUTPUT | ||
# echo "release=${release}" >> $GITHUB_OUTPUT | ||
# echo "version=${version}" >> $GITHUB_OUTPUT | ||
# Output | ||
echo "tag=${tag}" >> $GITHUB_OUTPUT | ||
echo "release=${release}" >> $GITHUB_OUTPUT | ||
echo "version=${version}" >> $GITHUB_OUTPUT | ||
### Deploy | ||
# - name: Stop pre-existing deployments on PRs (status = pending-upgrade) | ||
# if: github.event_name == 'pull_request' | ||
# uses: bcgov/[email protected] | ||
# with: | ||
# oc_namespace: ${{ secrets.oc_namespace }} | ||
# oc_token: ${{ secrets.oc_token }} | ||
# oc_server: ${{ vars.oc_server }} | ||
# triggers: ${{ inputs.triggers }} | ||
# commands: | | ||
# # 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 | ||
- name: Stop pre-existing deployments on PRs (status = pending-upgrade) | ||
if: github.event_name == 'pull_request' | ||
uses: bcgov/[email protected] | ||
with: | ||
oc_namespace: ${{ secrets.oc_namespace }} | ||
oc_token: ${{ secrets.oc_token }} | ||
oc_server: ${{ vars.oc_server }} | ||
triggers: ${{ inputs.triggers }} | ||
commands: | | ||
# 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 | ||
- name: Helm Deploy | ||
id: deploy | ||
|
@@ -149,39 +148,28 @@ jobs: | |
oc_server: ${{ vars.oc_server }} | ||
triggers: ${{ inputs.triggers }} | ||
commands: | | ||
oc whoami | ||
# # Deploy | ||
# # If directory provided, cd to it | ||
# [ -z "${{ inputs.directory }}" ]|| cd ${{ inputs.directory }} | ||
# # 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 || steps.vars.outputs.version }} | ||
# # Helm upgrade/rollout | ||
# helm upgrade \ | ||
# --set-string global.repository=${{ github.repository }} \ | ||
# --set-string global.tag=${{ steps.vars.outputs.tag }} \ | ||
# --set-string global.config.databaseUser=${{ inputs.db_user }} \ | ||
# ${{ inputs.params }} \ | ||
# --install --wait ${{ inputs.atomic && '--atomic' || '' }} ${{ steps.vars.outputs.release }} \ | ||
# --timeout ${{ inputs.timeout-minutes }}m \ | ||
# --values ${{ inputs.values }} \ | ||
# ./${{ github.event.repository.name }}-${{ steps.pr.outputs.pr || steps.vars.outputs.version }}.tgz | ||
# # Helm release history | ||
# helm history ${{ steps.vars.outputs.release }} | ||
# # Completed pod cleanup | ||
# oc delete po --field-selector=status.phase==Succeeded || true | ||
- env: | ||
results: ${{ toJSON(steps.deploy) }} | ||
run: | | ||
# Verify outputs | ||
echo "Outputs: ${{ env.results }}" | ||
if [ "${{ steps.deploy.outputs.triggered }}" != "true" ]; then | ||
echo "Error! Verify outputs." | ||
exit 1 | ||
fi | ||
# Deploy | ||
# If directory provided, cd to it | ||
[ -z "${{ inputs.directory }}" ]|| cd ${{ inputs.directory }} | ||
# 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 || steps.vars.outputs.version }} | ||
# Helm upgrade/rollout | ||
helm upgrade \ | ||
--set-string global.repository=${{ github.repository }} \ | ||
--set-string global.tag=${{ steps.vars.outputs.tag }} \ | ||
--set-string global.config.databaseUser=${{ inputs.db_user }} \ | ||
${{ inputs.params }} \ | ||
--install --wait ${{ inputs.atomic && '--atomic' || '' }} ${{ steps.vars.outputs.release }} \ | ||
--timeout ${{ inputs.timeout-minutes }}m \ | ||
--values ${{ inputs.values }} \ | ||
./${{ github.event.repository.name }}-${{ steps.pr.outputs.pr || steps.vars.outputs.version }}.tgz | ||
# Helm release history | ||
helm history ${{ steps.vars.outputs.release }} | ||
# 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 |
---|---|---|
|
@@ -10,26 +10,26 @@ concurrency: | |
|
||
jobs: | ||
# https://github.com/bcgov-nr/action-builder-ghcr | ||
# builds: | ||
# name: Builds | ||
# runs-on: ubuntu-24.04 | ||
# strategy: | ||
# matrix: | ||
# package: [backend, frontend, migrations] | ||
# timeout-minutes: 10 | ||
# steps: | ||
# - uses: bcgov/[email protected] | ||
# with: | ||
# keep_versions: 50 | ||
# package: ${{ matrix.package }} | ||
# tag: ${{ github.event.number }} | ||
# tag_fallback: latest | ||
# triggers: ('${{ matrix.package }}/') | ||
builds: | ||
name: Builds | ||
runs-on: ubuntu-24.04 | ||
strategy: | ||
matrix: | ||
package: [backend, frontend, migrations] | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: bcgov/[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 (${{ github.event.number }}) | ||
# needs: [builds] | ||
needs: [builds] | ||
uses: ./.github/workflows/.deployer.yml | ||
secrets: | ||
oc_namespace: ${{ secrets.OC_NAMESPACE }} | ||
|
@@ -47,27 +47,12 @@ jobs: | |
with: | ||
target: ${{ github.event.number }} | ||
|
||
verify: | ||
name: Verify Results | ||
needs: [deploys] | ||
results: | ||
name: PR Results | ||
needs: [builds, deploys, tests] | ||
if: always() | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- env: | ||
results: ${{ toJSON(needs) }} | ||
run: | | ||
# Verify outputs | ||
echo "Outputs: ${{ env.results }}" | ||
if [ "${{ needs.deploy.outputs.triggered }}" != "true" ]; then | ||
echo "Error! Verify outputs." | ||
exit 1 | ||
fi | ||
# results: | ||
# name: PR Results | ||
# needs: [builds, deploys, tests] | ||
# if: always() | ||
# runs-on: ubuntu-24.04 | ||
# steps: | ||
# - if: contains(needs.*.result, 'failure')||contains(needs.*.result, 'canceled') | ||
# run: echo "At least one job has failed." && exit 1 | ||
# - run: echo "Success!" | ||
- if: contains(needs.*.result, 'failure')||contains(needs.*.result, 'canceled') | ||
run: echo "At least one job has failed." && exit 1 | ||
- run: echo "Success!" |