|
74 | 74 | IMAGE_RELEASE=$(echo ${IMAGE_INFO} | jq -r '.Labels.build_version' | awk '{print $3}')
|
75 | 75 | IMAGE_VERSION=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $1}')
|
76 | 76 | NB_RELEASE_NUMBER=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $2}')
|
77 |
| - TAG_SHA=$(git rev-list -n 1 ${IMAGE_RELEASE} 2>/dev/null || echo "") |
| 77 | + if git rev-parse --verify "refs/tags/${IMAGE_RELEASE}" >/dev/null 2>&1; then |
| 78 | + TAG_SHA=$(git rev-list -n 1 ${IMAGE_RELEASE}) |
| 79 | + else |
| 80 | + TAG_SHA="" |
| 81 | + fi |
78 | 82 | if [ -z "${MULTIDIGEST}" ] || [ "${MULTIDIGEST}" == "null" ]; then
|
79 | 83 | echo "**** No existing container build found, assuming first build ****"
|
80 | 84 | VERSION_TAG=${WEBAPP_RELEASE}-nbxyz1
|
@@ -138,8 +142,20 @@ jobs:
|
138 | 142 | ghcr.io/netbootxyz/netbootxyz:${{ env.VERSION_TAG }}
|
139 | 143 | labels: ${{ steps.meta.outputs.labels }}
|
140 | 144 |
|
141 |
| - - name: Bump version and push tag |
| 145 | + - name: Check if tag exists |
142 | 146 | if: steps.version_check.outcome == 'success' && steps.version_check.conclusion == 'success'
|
| 147 | + id: check_tag |
| 148 | + run: | |
| 149 | + if git rev-parse --verify "refs/tags/${{ env.VERSION_TAG }}" >/dev/null 2>&1; then |
| 150 | + echo "Tag ${{ env.VERSION_TAG }} already exists, skipping tag creation" |
| 151 | + echo "tag_exists=true" >> $GITHUB_OUTPUT |
| 152 | + else |
| 153 | + echo "Tag ${{ env.VERSION_TAG }} does not exist, will create" |
| 154 | + echo "tag_exists=false" >> $GITHUB_OUTPUT |
| 155 | + fi |
| 156 | +
|
| 157 | + - name: Bump version and push tag |
| 158 | + if: steps.version_check.outcome == 'success' && steps.version_check.conclusion == 'success' && steps.check_tag.outputs.tag_exists == 'false' |
143 | 159 | id: tag_version
|
144 | 160 | uses: anothrNick/[email protected]
|
145 | 161 | env:
|
|
0 commit comments