-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (43 loc) · 1.98 KB
/
golden-image-ids-comparison.yaml
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
name: Golden image IDs comparison
on:
schedule:
- cron: 0 0 * * 0
workflow_dispatch:
permissions:
contents: write
jobs:
compare-images-ids:
runs-on: ubuntu-latest
steps:
- name: Get images list
env:
OCI_CLI_TENANCY: ${{ vars.TF_VAR_TENANCY_OCID }}
OCI_CLI_USER: ${{ vars.TF_VAR_USER_OCID }}
OCI_CLI_KEY_CONTENT: ${{ secrets.TF_VAR_PRIVATE_KEY }}
OCI_CLI_FINGERPRINT: ${{ vars.TF_VAR_FINGERPRINT }}
OCI_CLI_REGION: ${{ vars.OCI_REGION }}
uses: oracle-actions/[email protected]
id: images-list
with:
command: compute image list --compartment-id "${{ env.OCI_CLI_TENANCY }}" --sort-by TIMECREATED --sort-order DESC --all
- name: Get the latest image ID
id: latest-image-id
run: |
latest_image_id=$(echo ${{ steps.images-list.outputs.output }} | \
jq -r '[.data[] | select(.["display-name"]|test("^Canonical-Ubuntu-22.04-aarch64-([\\.0-9-]+)$")) | .["id"]] | .[0]')
echo "latest_image_id=${latest_image_id}" >> $GITHUB_OUTPUT
- name: Get base image ID of the latest golden image
id: latest-golden-image-base-image-id
run: |
latest_golden_image_base_image_id=$(echo ${{ steps.images-list.outputs.output }} | \
jq -r '[.data[] | select(.["display-name"]|test("^golden-image-([TZ0-9-:]+)$")) | .["base-image-id"]] | .[0]')
echo "latest_golden_image_base_image_id=${latest_golden_image_base_image_id}" >> $GITHUB_OUTPUT
- name: Compare images IDs and set flag
if: ${{ steps.latest-image-id.outputs.latest_image_id != steps.latest-golden-image-base-image-id.outputs.latest_golden_image_base_image_id }}
id: images-comparison
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PUSH_TOKEN }}
repository: hajle-silesia/provisioning
event-type: golden-image-ids-comparison
client-payload: '{"unequal_flag": "true"}'