Skip to content

chore: upgrade metabase #355

chore: upgrade metabase

chore: upgrade metabase #355

Workflow file for this run

name: PR
on:
pull_request:
branches: [main]
concurrency:
# PR open and close use the same group, allowing only one at a time
group: pr-${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
extract_version:
name: Extract Version
if: (!github.event.pull_request.head.repo.fork)
runs-on: ubuntu-24.04
outputs:
app_version: ${{ steps.read_yaml.outputs.app_version }}
available: ${{ steps.read_yaml.outputs.available }}
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
- name: Extract Version
id: read_yaml
shell: bash
run: |
appVersion="$(bash .github/scripts/get-metabase-version.sh)"
echo "app version is $appVersion"
echo "app_version=$appVersion" >> "$GITHUB_OUTPUT"
echo "available=$([ -n "$appVersion" ] && echo true || echo false)" >> "$GITHUB_OUTPUT"
- name: Get App Version
run: echo "${{ steps.read_yaml.outputs.app_version }}"
builds:
name: Builds
needs: extract_version
if: (needs.extract_version.outputs.available == 'true')
runs-on: ubuntu-24.04
permissions:
packages: write
steps:
- uses: bcgov/actions/builder-ghcr@0992e41cd11c5370b77f9e6066effe63efe9f8c9 # v0.4.0
with:
package: metabase
tags: ${{ github.sha }}
build_args: |
METABASE_VERSION=${{ needs.extract_version.outputs.app_version }}
- uses: shrink/actions-docker-registry-tag@e6aaef25c595b6e0edd18bf4c7dbfea3abd43299 # v5
with:
registry: ghcr.io
repository: ${{ github.repository }}/metabase
target: ${{ github.sha }}
tags: |
${{ github.event.number }}
deploys:
name: Deploys
needs: [builds]
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- name: Deploy to OpenShift
uses: bcgov/action-oc-runner@111868d1fc50db0a40417ba321d865ef5c931bbd # v1.7.0
env:
DB_HOST_PORT: ${{ secrets.DB_HOST_PORT_ENV }}
with:
oc_namespace: ${{ vars.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
oc_server: ${{ vars.OC_SERVER }}
commands: |
# Retry function with exponential backoff (up to 10 attempts)
retry_with_backoff() {
local max_attempts=10
local timeout=300 # 5 minutes per attempt
local attempt=1
local exit_code=0
while [ $attempt -le $max_attempts ]; do
echo "Deployment attempt $attempt/$max_attempts"
# Deploy Helm Chart
timeout $timeout helm upgrade --install --wait --atomic nr-metabase-${{ github.event.number }} \
--set-literal metabase.dbHostPortEnv="${DB_HOST_PORT}" \
--set-string global.secrets.databasePassword="${{ secrets.DB_PASSWORD}}" \
--set-string global.zone="${{ github.event.number }}" \
--set-string metabase.metabaseImage.tag="${{ github.sha }}" \
--set-string namespace="${{ vars.oc_namespace }}" \
--timeout 5m charts/nr-metabase --debug
exit_code=$?
if [ $exit_code -eq 0 ]; then
echo "Deployment succeeded on attempt $attempt"
return 0
fi
if [ $attempt -lt $max_attempts ]; then
# Exponential backoff: 2^(attempt-1) seconds, max 60 seconds
local backoff=$((2 ** (attempt - 1)))
if [ $backoff -gt 60 ]; then
backoff=60
fi
echo "Deployment failed (exit code: $exit_code). Retrying in ${backoff}s..."
sleep $backoff
else
echo "Deployment failed after $max_attempts attempts"
return $exit_code
fi
((attempt++))
done
}
retry_with_backoff