Skip to content

Update dependencies image versions #650

Update dependencies image versions

Update dependencies image versions #650

name: Update dependencies image versions
on:
schedule:
- cron: '0 0 * * *'
repository_dispatch: {}
workflow_dispatch: {}
env:
IMG_REPO_URL: https://quay.io/api/v1/repository/kuadrant/
GH_API_ORG_ENDPOINT: https://api.github.com/orgs/Kuadrant/actions/variables/
jobs:
get-latest-sha:
name: Get projects latest SHA
runs-on: ubuntu-latest
permissions:
actions: write
strategy:
fail-fast: true
matrix:
repository:
- authorino
- authorino-operator
- limitador
- limitador-operator
- wasm-shim
- dns-operator
steps:
- name: Fetch dependencies images list
id: fetch
uses: fjogeleit/http-request-action@v1
with:
method: 'GET'
url: ${{env.IMG_REPO_URL}}${{ matrix.repository }}?includeTags=true
- name: Parse the list to get the last SHA
id: extract-sha-var
run: |
echo "sha=$(echo '${{ steps.fetch.outputs.response }}' | jq -c -r '.tags | to_entries | sort_by(.value.last_modified | strptime("%a, %d %b %Y %H:%M:%S -0000"))[].key | select(.|test("[0-9a-f]{5,40}"))' | jq -Rn '[inputs]' | jq -c -r '.[-1]')" >> $GITHUB_OUTPUT
echo "var=$(echo ${{ matrix.repository }} | sed -E 's/-/_/g;s/[a-z]/\U&/g')_SHA" >> $GITHUB_OUTPUT
- name: Update stored variable
id: update
run: |
var=$(echo ${{ matrix.repository }} | sed -E 's/-/_/g;s/[a-z]/\U&/g')_SHA
http_code=$(curl --write-out "%{http_code}\n" -L -X PATCH "${{env.GH_API_ORG_ENDPOINT}}${{steps.extract-sha-var.outputs.var}}" -H "X-GitHub-Api-Version: 2022-11-28" -H 'Authorization: Bearer ${{ secrets.UPDATE_ACTION_VARS_TOKEN }}' -H 'Accept: application/vnd.github+json' -d '{ "value": "${{ steps.extract-sha-var.outputs.sha }}" }')
if [[ $http_code != 204 ]]; then
exit 1
fi