Golden images ID comparison #16
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: 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"}' |