-
Notifications
You must be signed in to change notification settings - Fork 33
47 lines (44 loc) · 1.84 KB
/
update-stored-dependencies-version.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: 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://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