Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions .github/workflows/.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ jobs:
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v7
- name: Stop pre-existing deployments on PRs (status = pending-upgrade)
if: github.event_name == 'pull_request'
- name: Stop pre-existing deployments (status = pending-*)
uses: bcgov/action-oc-runner@111868d1fc50db0a40417ba321d865ef5c931bbd # v1.7.0
with:
oc_namespace: ${{ vars.oc_namespace }}
Expand All @@ -72,12 +71,18 @@ jobs:
triggers: ${{ inputs.triggers }}
commands: |
set -euo pipefail
# Interrupt any previous deployments (PR only)
# Interrupt any previous deployments
PREVIOUS=$(helm status ${{ inputs.release_name }} -o json | jq .info.status || true)
if [[ ${PREVIOUS} =~ pending ]]; then
echo "Rollback triggered"
helm rollback ${{ inputs.release_name }} || \
helm uninstall ${{ inputs.release_name }}
if [ -n "${{ inputs.environment }}" ]; then
# Safe rollback only; never uninstall persistent environments (prod/test)
helm rollback ${{ inputs.release_name }}
else
# Fallback to uninstall permitted for ephemeral PR deployments
helm rollback ${{ inputs.release_name }} || \
helm uninstall ${{ inputs.release_name }}
fi
fi

- name: Deploy
Expand Down Expand Up @@ -111,6 +116,12 @@ jobs:
if [ -n "${{ inputs.params }}" ]; then
PARAMS+="${{ inputs.params }}"
fi
# Force-delete database PVCs ONLY in ephemeral Pull Request (DEV) environments.
# For all persistent/formal environments (TEST, PROD, dispatches), we fall back
# to the safe default (keep: true in values.yaml) to prevent accidental data loss.
if [ -z "${{ inputs.environment }}" ] && [ "${{ github.event_name }}" = "pull_request" ]; then
PARAMS+=" --set database.pvc.keep=false"
fi
echo "PARAMS: $PARAMS"
echo "COMMANDS: $COMMANDS"
helm upgrade $PARAMS $COMMANDS pubcode.tgz
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
cancel-in-progress: false

permissions: {}

Expand Down
4 changes: 4 additions & 0 deletions charts/pubcode/templates/database/templates/pvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-database
namespace: {{ .Release.Namespace }}
{{- if .Values.database.pvc.keep }}
annotations:
"helm.sh/resource-policy": keep
{{- end }}
labels:
{{- include "database.labels" . | nindent 4 }}
spec:
Expand Down
1 change: 1 addition & 0 deletions charts/pubcode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,4 @@ database:
size: 750Mi
storageClassName: netapp-file-standard
accessModes: ReadWriteMany
keep: true
Loading