Skip to content
Draft
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
92 changes: 92 additions & 0 deletions .github/workflows/db-backup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Create Central DB backup
on:
workflow_dispatch:
inputs:
version:
description: Release version (A.B.C)
required: true
default: 0.0.0
type: string
dry-run:
description: Dry-run
required: false
default: false
type: boolean
pull_request: # Only for testing, remove before merge

# Ensure that only a single automation workflow can run at a time for each release.
concurrency: Central DB backup ${{ inputs.version }}

jobs:
variables:
name: Setup variables
uses: ./.github/workflows/variables.yml
with:
# Remove the 4.11.0 fallback before merging
version: ${{ github.event.inputs.version || '4.11.0' }}
assert-format: A.B.C

create-backup:
runs-on: ubuntu-latest
needs:
- variables
env:
KUBECONFIG: "/tmp/kubeconfig"
RELEASE: ${{ needs.variables.outputs.release }}
PATCH: ${{ needs.variables.outputs.patch }}
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # ratchet:actions/checkout@v7.0.0

- uses: ./.github/actions/job-preamble
with:
gcp-account: ${{ secrets.GCP_SERVICE_ACCOUNT_STACKROX_CI }}

- name: Login to Quay.io
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # ratchet:docker/login-action@v4
with:
registry: quay.io
username: ${{ secrets.QUAY_RHACS_ENG_RO_USERNAME }}
password: ${{ secrets.QUAY_RHACS_ENG_RO_PASSWORD }}

- name: Install roxctl
uses: stackrox/roxctl-installer-action@47fb4f5b275066b8322369e6e33fa010915b0d13 # ratchet:stackrox/roxctl-installer-action@v1
with:
roxctl-release: latest

- name: Retrieving roxie version from repository
id: roxie-version
run: echo "version=$(cat ROXIE_VERSION)" >> "$GITHUB_OUTPUT"

- name: Install roxie
uses: stackrox/actions/roxie/install-cli@6691d5c300d4af17546145bdbbb9862c53975af4 # ratchet:stackrox/actions@v1
with:
version: "v${{ steps.roxie-version.outputs.version }}"

- name: Create k8s Kind Cluster
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # ratchet:helm/kind-action@v1
with:
kubeconfig: "${{ env.KUBECONFIG }}"

- name: Deploy Central
id: deploy-central
run: |
roxie_envrc="$(mktemp)"
echo "roxie-envrc=${roxie_envrc}" >> "$GITHUB_OUTPUT"

roxie deploy central \
--tag "${RELEASE}.${PATCH}" \
--resources auto \
--port-forwarding \
--envrc "${roxie_envrc}" \
--central-wait 5m

- name: Grab a central backup
run: |
source "${{ steps.deploy-central.outputs.roxie-envrc }}"
roxctl central backup --output "postgres_db_${RELEASE}.${PATCH}.sql.zip"

- name: Upload backup as an artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # ratchet:actions/upload-artifact@v7
with:
path: postgres_db_*.sql.zip
Loading