Oracle: Schedule Deletion of DBIDs Not In Use (Delete Obsolete Backups) #45
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: Schedule Deletion of DBIDs Not In Use (Delete Obsolete Backups)" | |
on: | |
schedule: | |
- cron: '10 11 * * MON' | |
- cron: '10 11 * * TUE' | |
- cron: '10 11 * * WED' | |
- cron: '10 11 * * THU' | |
jobs: | |
prepare-run-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
scheduled_matrix: ${{ steps.filter-dbid-deletion-schedule.outputs.scheduling_matrix }} | |
steps: | |
- name: Checkout DBIDs Deletion Schedule | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout-cone-mode: false | |
sparse-checkout: | | |
.github/workflows/oracle-db-delete-dbids-not-in-use-schedule.json | |
path: operations | |
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.SourceCodeVersion || 'main' }} | |
fetch-depth: 0 | |
- name: Filter DBID Deletion Schedule | |
id: filter-dbid-deletion-schedule | |
run: | | |
SCHEDULED_JSON=$(jq '[.[] | select (.CronSchedule=="${{ github.event.schedule }}") | {"TargetEnvironment","TargetHost"}]' operations/.github/workflows/oracle-db-delete-dbids-not-in-use-schedule.json | jq '{include: .}') | |
echo "scheduling_matrix="$(echo ${SCHEDULED_JSON} | sed 's/ //g') >> $GITHUB_OUTPUT | |
report-dbids-deletion: | |
needs: prepare-run-matrix | |
runs-on: ubuntu-latest | |
if: ${{ needs.prepare-run-matrix.outputs.scheduled_matrix != '{"include":[]}' }} | |
steps: | |
- name: Report DBID Deletion Scheduled to Run | |
id: report-run | |
run: | | |
echo "Running Deletion of DBIDs not in use (Obsolete Backups) for these targets: ${{ needs.prepare-run-matrix.outputs.scheduled_matrix }}" | |
report-no-dbids-deletion: | |
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 deletion of DBIDs not in use." | |
dbids-not-in-use-deletion: | |
needs: prepare-run-matrix | |
if: ${{ needs.prepare-run-matrix.outputs.scheduled_matrix != '{"include":[]}' }} | |
strategy: | |
matrix: ${{fromJson(needs.prepare-run-matrix.outputs.scheduled_matrix)}} | |
name: DBIDs Not In Use Deletion | |
uses: | |
ministryofjustice/hmpps-delius-operational-automation/.github/workflows/oracle-db-delete-dbids-not-in-use.yml@main | |
with: | |
TargetEnvironment: ${{ matrix.TargetEnvironment }} | |
TargetHost: ${{ matrix.TargetHost }} |