generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (56 loc) · 2.36 KB
/
oracle-db-password-rotation-schedule.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
name: "Oracle: Schedule Password Rotation"
on:
schedule:
- cron: '00 12 * * TUE'
- cron: '00 14 * * TUE'
- cron: '00 10 * * THU'
- cron: '00 14 * * THU'
jobs:
prepare-run-matrix:
runs-on: ubuntu-latest
outputs:
scheduled_matrix: ${{ steps.filter-password-rotation-schedule.outputs.scheduling_matrix }}
steps:
- name: Checkout Password Rotation Schedule
uses: actions/checkout@v4
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
.github/workflows/oracle-db-password-rotation-schedule.json
path: operations
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.SourceCodeVersion || 'main' }}
fetch-depth: 0
- name: Filter Password Rotation Schedule
id: filter-password-rotation-schedule
run: |
SCHEDULED_JSON=$(jq '[.[] | select (.CronSchedule=="${{ github.event.schedule }}") | {"TargetEnvironment"}]' operations/.github/workflows/oracle-db-password-rotation-schedule.json | jq '{include: .}')
echo "scheduling_matrix="$(echo ${SCHEDULED_JSON} | sed 's/ //g') >> $GITHUB_OUTPUT
report-schedule-password-rotation:
needs: prepare-run-matrix
runs-on: ubuntu-latest
if: ${{ needs.prepare-run-matrix.outputs.scheduled_matrix != '{"include":[]}' }}
steps:
- name: Report Password Rotation Scheduled to Run
id: report-run
run: |
echo "Running Password Rotation for these targets: ${{ needs.prepare-run-matrix.outputs.scheduled_matrix }}"
report-no-scheduled-password-rotation:
needs: prepare-run-matrix
runs-on: ubuntu-latest
if: ${{ needs.prepare-run-matrix.outputs.scheduled_matrix == '{"include":[]}' }}
steps:
- name: Report Nothing to Do
id: report-no-run
run: |
echo "No target environments scheduled for password rotation run."
password-rotation:
needs: prepare-run-matrix
if: ${{ needs.prepare-run-matrix.outputs.scheduled_matrix != '{"include":[]}' }}
strategy:
fail-fast: false
matrix: ${{fromJson(needs.prepare-run-matrix.outputs.scheduled_matrix)}}
name: Password Rotation
uses:
ministryofjustice/hmpps-delius-operational-automation/.github/workflows/oracle-db-password-rotation.yml@main
with:
TargetEnvironment: ${{ matrix.TargetEnvironment }}