add db refresh from paas to aks #4
Workflow file for this run
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
name: Backup and restore Postgres DB from PAAS to AKS | |
on: | |
push: | |
branches: | |
- 365-enable-daily-database-refresh-from-paas-to-aks | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: choice | |
options: | |
- dev | |
jobs: | |
backup: | |
name: Backup from PAAS | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- run: | | |
echo "Hello World" | |
- uses: actions/checkout@v4 | |
- uses: Azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- uses: DFE-Digital/github-actions/install-postgres-client@master | |
- name: Set environment variables | |
shell: bash | |
run: | | |
tf_vars_file=terraform/paas/workspace_variables/dev.tfvars.json | |
echo "KEY_VAULT_NAME=$(jq -r '.key_vault_name' ${tf_vars_file})" >> $GITHUB_ENV | |
echo "PAAS_SPACE=$(jq -r '.paas_space' ${tf_vars_file})" >> $GITHUB_ENV | |
- name: Retrieve Cloudfoundry credentials from KV | |
uses: azure/CLI@v1 | |
id: fetch-cf-creds | |
with: | |
inlineScript: | | |
SECRET_VALUE=$(az keyvault secret show --name "PAAS-USER" --vault-name "${{ env.KEY_VAULT_NAME}}" --query "value" -o tsv) | |
echo "::add-mask::$SECRET_VALUE" | |
echo "PAAS-USER=$SECRET_VALUE" >> $GITHUB_OUTPUT | |
SECRET_VALUE=$(az keyvault secret show --name "PAAS-PASSWORD" --vault-name "${{ env.KEY_VAULT_NAME}}" --query "value" -o tsv) | |
echo "::add-mask::$SECRET_VALUE" | |
echo "PAAS-PASSWORD=$SECRET_VALUE" >> $GITHUB_OUTPUT | |
- uses: DFE-Digital/github-actions/setup-cf-cli@master | |
with: | |
CF_USERNAME: ${{ steps.fetch-cf-creds.outputs.PAAS-USER }} | |
CF_PASSWORD: ${{ steps.fetch-cf-creds.outputs.PAAS-PASSWORD }} | |
CF_SPACE_NAME: ${{ env.PAAS_SPACE }} | |
INSTALL_CONDUIT: true | |
- name: Backup database | |
run: | | |
cf conduit find-a-lost-trn-dev-pg-svc -- pg_dump -E utf8 --clean --compress=1 --if-exists --no-owner --no-privileges --verbose -f backup.sql.gz | |