Skip to content

Update dependencies image versions #191

Update dependencies image versions

Update dependencies image versions #191

name: Update dependencies image versions
on:
schedule:
- cron: '0 0 * * *'
repository_dispatch: {}
env:
IMG_REPO_URL: https://quay.io/api/v1/repository/kuadrant/
GH_API_ORG_ENDPOINT: https://github.com/gitapi/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
steps:
- name: Fetch dependencies images list
id: fetch
uses: fjogeleit/http-request-action@master
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 | keys_unsorted | .[] | select(.|test("[0-9a-f]{5,40}"))' | jq -Rn '[inputs]' | jq -c -r '.[0]')" >> $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