Skip to content

Commit

Permalink
Merge pull request #93 from norcalipa/noraclipa/update-latest-image-l…
Browse files Browse the repository at this point in the history
…abel-2

Adding latest label - part 2
  • Loading branch information
norcalipa authored Apr 4, 2024
2 parents 81df253 + eff8dda commit 11f2ca8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/update-latest-image-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ jobs:
- name: Get latest package version
id: latest-version
run: |
VERSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/user/packages/container/crank/versions | jq -r '.[0].metadata.container.tags[0]')
echo "::set-output name=version::$VERSION"
JSON_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/user/packages/container/crank/versions)
if [ $(echo $JSON_RESPONSE | jq '. | length') -gt 0 ] && [ $(echo $JSON_RESPONSE | jq '.[0].metadata.container.tags | length') -gt 0 ]; then
VERSION=$(echo $JSON_RESPONSE | jq -r '.[0].metadata.container.tags[0]')
echo "::set-output name=version::$VERSION"
fi
- name: Update latest label
run: |
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/user/packages/container/crank/versions/${{ steps.latest-version.outputs.version }}/labels -d '{"labels": ["latest"]}'
if [ -n "${{ steps.latest-version.outputs.version }}" ]; then
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/user/packages/container/crank/versions/${{ steps.latest-version.outputs.version }}/labels -d '{"labels": ["latest"]}'
fi

0 comments on commit 11f2ca8

Please sign in to comment.