Skip to content

Commit

Permalink
Fix CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
agrojean-ledger committed Jul 21, 2023
1 parent e97d73d commit 0215759
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,19 @@ jobs:

- name: Check already existing image
run: |
GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
TAGS=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/${REPO_NAME,,}/tags/list)
GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
TAGS_FULL=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/${REPO_NAME,,}/tags/list)
TAGS_LITE=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/${REPO_NAME,,}-lite/tags/list)
TAGS_LEGACY=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/${REPO_NAME,,}-legacy/tags/list)
TAGS_DEV_TOOLS=$(curl -H "Authorization: Bearer ${GHCR_TOKEN}" https://ghcr.io/v2/${REPO_PATH,,}/ledger-app-dev-tools/tags/list)
# Concatenate all tags from json fields in one string
CONCATENATE_TAG_FIELDS=$(echo $TAGS_FULL $TAGS_LITE $TAGS_LEGACY $TAGS_DEV_TOOLS | jq -s '.[0].tags + .[1].tags + .[2].tags + .[3].tags')
TAG_TO_FIND=${{ steps.get-current-version.outputs.current_version }}
RESULT=$(echo "$TAGS" | jq --arg tag "$TAG_TO_FIND" '.tags | map(select(. == $tag))')
# Find if TAG_TO_FIND is in CONCATENATE_TAG_FIELDS string (with grep)
RESULT=$(echo $CONCATENATE_TAG_FIELDS | grep -o $TAG_TO_FIND)
# Echo all tags
echo $CONCATENATE_TAG_FIELDS
echo "RESULT: $RESULT"
if [[ "${RESULT}" != "[]" ]]; then
echo "An image tagged with the latest changelog version already exists on GHCR. Please update the changelog."
exit 1
Expand Down

0 comments on commit 0215759

Please sign in to comment.