Oracle: delius-core-dev-delius_standbydb1-snapshot-standby #33
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: "Oracle: Snapshot Standby" | |
run-name: "Oracle: ${{ format('{0}-{1}', github.event.inputs.TargetEnvironment, github.event.inputs.TargetHost) }}-snapshot-standby" | |
on: | |
workflow_dispatch: | |
inputs: | |
TargetEnvironment: | |
description: "Target environment" | |
required: true | |
type: choice | |
options: | |
- "delius-core-dev" | |
- "delius-core-test" | |
- "delius-core-training" | |
- "delius-core-stage" | |
- "delius-core-pre-prod" | |
- "delius-core-prod" | |
TargetHost: | |
description: "Select standby database" | |
type: choice | |
options: | |
- "delius_standbydb1" | |
- "delius_standbydb2" | |
Action: | |
description: "Select action to perform" | |
type: choice | |
options: | |
- "Convert Physical To Snapshot" | |
- "Convert Snapshot To Physical" | |
PushAudit: | |
description: "Push audit data back to primary before converting" | |
type: choice | |
default: "yes" | |
options: | |
- "yes" | |
- "no" | |
SourceCodeVersion: | |
description: "Source version for the hmpps-delius-operation-automation. Enter a pull request, branch, commit ID, tag, or reference." | |
type: string | |
default: "main" | |
SourceConfigVersion: | |
description: "Source version for the modernisation-platform-configuration-management. Enter a pull request, branch, commit ID, tag, or reference." | |
type: string | |
default: "main" | |
env: | |
ansible_config: operations/playbooks/ansible.cfg | |
command: ansible-playbook operations/playbooks/oracle_snapshot_standby/playbook.yml | |
inventory: inventory/ansible | |
# Allow permissions on repository and docker image respectively | |
permissions: | |
contents: read | |
packages: read | |
id-token: write | |
jobs: | |
deployment: | |
name: oracle-db-snapshot-standby | |
environment: ${{ github.event.inputs.TargetEnvironment }} | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/ministryofjustice/hmpps-delius-operational-automation:0.1 | |
timeout-minutes: 1440 | |
continue-on-error: false | |
steps: | |
- name: Output Input Parameters | |
shell: bash | |
run: | | |
echo -e "Action: ${{ github.event.inputs.Action }}\n\ | |
PushAudit: ${{ github.event.inputs.PushAudit }}\n\ | |
SourceCodeVersion: ${{ github.event.inputs.SourceCodeVersion }}\n\ | |
SourceConfigVersion: ${{ github.event.inputs.SourceConfigVersion }}" | |
- name: Prepare Target Name | |
id: preparetargetname | |
run: echo TargetHost="environment_name_$(echo ${{ github.event.inputs.TargetEnvironment }} | sed 's/delius-core-dev/delius_core_development_dev/;s/delius-core-test/delius_core_test_test/;s/delius-core-training/delius_core_test_training/;s/delius-core-stage/delius_core_preproduction_stage/;s/delius-core-pre-prod/delius_core_preproduction_pre_prod/;s/delius-core-prod/delius_core_production_prod/')_${{ github.event.inputs.TargetHost }}" >> $GITHUB_OUTPUT | |
- name: Checkout hmpps-delius-operation-automation | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout-cone-mode: false | |
sparse-checkout: | | |
playbooks/oracle_snapshot_standby | |
playbooks/oracle_ha | |
playbooks/ansible.cfg | |
path: operations | |
ref: ${{ github.event.inputs.SourceCodeVersion }} | |
fetch-depth: 0 | |
- name: Checkout modernisation-platform-configuration-management | |
uses: actions/checkout@v4 | |
with: | |
repository: ministryofjustice/modernisation-platform-configuration-management | |
sparse-checkout-cone-mode: false | |
sparse-checkout: | | |
ansible/hosts | |
ansible/group_vars | |
path: inventory | |
ref: ${{ github.event.inputs.SourceConfigVersion }} | |
fetch-depth: 0 | |
- name: Configure AWS Credentials | |
id: login-aws | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: "arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/modernisation-platform-oidc-cicd" | |
role-session-name: "hmpps-delius-operational-automation-${{ github.run_number }}" | |
aws-region: "eu-west-2" | |
- name: Start Ansible Snapshot Standby | |
shell: bash | |
run: | | |
export ANSIBLE_CONFIG=$ansible_config | |
$command -i $inventory \ | |
-e hosts=${{ steps.preparetargetname.outputs.TargetHost }} \ | |
-e "action='${{ github.event.inputs.Action }}'" \ | |
-e push_audit=${{ github.event.inputs.PushAudit }} | |