generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (95 loc) · 3.91 KB
/
oracle-db-autotasks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: "Oracle: Autotask"
run-name: "Oracle: ${{ format('{0}_{1}', github.event.inputs.TargetEnvironment, github.event.inputs.TargetHost) }}_autotask"
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-preprod"
- "delius-core-prod"
- "delius-mis-dev"
- "delius-mis-stage"
- "delius-mis-preprod"
- "delius-mis-prod"
TargetHost:
description: "Database target host"
required: true
type: choice
options:
- "delius_primarydb"
- "mis_primarydb"
- "boe_primarydb"
- "dsd_primarydb"
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"
# Allow permissions on repository and docker image respectively
permissions:
contents: read
packages: read
id-token: write
jobs:
build_target_name:
runs-on: ubuntu-latest
outputs:
TargetHost: ${{ steps.preparetargetname.outputs.TargetHost }}
steps:
- name: Prepare Target Name
id: preparetargetname
run: echo TargetHost="environment_name_$(echo ${{ github.event.inputs.TargetEnvironment }} | sed 's/dev/development_dev/;s/test/test_test/;s/training/test_training/;s/stage/preproduction_stage/;s/pre-prod/preproduction_pre_prod/;s/-prod/_production_prod/;s/-/_/g')_${{ github.event.inputs.TargetHost }}" >> $GITHUB_OUTPUT
deployment:
name: oracle-db-autotask
needs: build_target_name
environment: ${{ github.event.inputs.TargetEnvironment }}
runs-on: ubuntu-latest
container:
image: ghcr.io/ministryofjustice/hmpps-delius-operational-automation:0.78.0
timeout-minutes: 1440
env:
command: ansible-playbook operations/ansible/roles/oracle-db-autotasks/configure_oracle_autotasks.yml
inventory: inventory/ansible
continue-on-error: false
steps:
- name: Checkout Role From modernisation-platform-configuration-management
uses: actions/checkout@v4
with:
repository: ministryofjustice/modernisation-platform-configuration-management
sparse-checkout-cone-mode: false
sparse-checkout: |
ansible/roles/oracle-db-autotasks
path: operations
ref: ${{ github.event.inputs.SourceConfigVersion }}
fetch-depth: 0
- name: Checkout Inventory From 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 }}"
role-duration-seconds: 21600
aws-region: "eu-west-2"
- name: Configure Oracle Autotasks
run: $command -i $inventory --e ansible_aws_ssm_bucket_name=${{ vars.ANSIBLE_AWS_SSM_BUCKET_NAME }} -e target_hosts=${{needs.build_target_name.outputs.TargetHost}}