Add debug

This commit is contained in:
Antony Messerli 2021-09-06 19:31:34 -05:00
parent 91665367ad
commit d52328dc2c

View File

@ -37,6 +37,9 @@ jobs:
username: ${{ secrets.GHCR_USER }} username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_TOKEN }} password: ${{ secrets.GHCR_TOKEN }}
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
- name: Determine version numbers - name: Determine version numbers
id: version_check id: version_check
continue-on-error: true continue-on-error: true
@ -46,44 +49,44 @@ jobs:
TOKEN=$(curl -sX GET \ TOKEN=$(curl -sX GET \
"https://ghcr.io/token?scope=repository%3Anetbootxyz%2Fnetbootxyz%3Apull" \ "https://ghcr.io/token?scope=repository%3Anetbootxyz%2Fnetbootxyz%3Apull" \
| jq -r '.token') | jq -r '.token')
MULTIDIGEST=$(curl -s \ MULTIDIGEST=$(curl -s \
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
--header "Authorization: Bearer ${TOKEN}" \
"https://ghcr.io/v2/${IMAGE}/manifests/${tag}" \
| jq -r 'first(.manifests[].digest)')
DIGEST=$(curl -s \
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
--header "Authorization: Bearer ${TOKEN}" \
"https://ghcr.io/v2/${IMAGE}/manifests/${MULTIDIGEST}" \
| jq -r '.config.digest')
IMAGE_INFO=$(curl -sL \
--header "Authorization: Bearer ${TOKEN}" \ --header "Authorization: Bearer ${TOKEN}" \
"https://ghcr.io/v2/${IMAGE}/blobs/${DIGEST}" \ "https://ghcr.io/v2/${IMAGE}/manifests/${tag}" \
| jq -r '.config') | jq -r 'first(.manifests[].digest)')
IMAGE_RELEASE=$(echo ${IMAGE_INFO} | jq -r '.Labels.build_version' | awk '{print $3}') DIGEST=$(curl -s \
IMAGE_VERSION=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $1}') --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
NB_RELEASE_NUMBER=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $2}') --header "Authorization: Bearer ${TOKEN}" \
TAG_SHA=$(git rev-list -n 1 ${IMAGE_RELEASE}) "https://ghcr.io/v2/${IMAGE}/manifests/${MULTIDIGEST}" \
if [ -z "${MULTIDIGEST}" ] || [ "${MULTIDIGEST}" == "null" ]; then | jq -r '.config.digest')
echo "**** No existing container build found, assuming first build ****" IMAGE_INFO=$(curl -sL \
VERSION_TAG=${WEBAPP_RELEASE}-nbxyz1 --header "Authorization: Bearer ${TOKEN}" \
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV "https://ghcr.io/v2/${IMAGE}/blobs/${DIGEST}" \
elif [ "${WEBAPP_RELEASE}" == "${IMAGE_VERSION}" ]; then | jq -r '.config')
echo "**** Version ${WEBAPP_RELEASE} unchanged, checking if there is anything to build..." IMAGE_RELEASE=$(echo ${IMAGE_INFO} | jq -r '.Labels.build_version' | awk '{print $3}')
if [ "${TAG_SHA}" == "${GITHUB_SHA}" ]; then IMAGE_VERSION=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $1}')
echo "**** Nothing to do, exiting build... **** " NB_RELEASE_NUMBER=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $2}')
exit 1 TAG_SHA=$(git rev-list -n 1 ${IMAGE_RELEASE})
else if [ -z "${MULTIDIGEST}" ] || [ "${MULTIDIGEST}" == "null" ]; then
echo "**** Changes found... incrementing build number version... ****" echo "**** No existing container build found, assuming first build ****"
NB_RELEASE_NUMBER=$((NB_RELEASE_NUMBER + 1)) VERSION_TAG=${WEBAPP_RELEASE}-nbxyz1
VERSION_TAG=${IMAGE_VERSION}-nbxyz${NB_RELEASE_NUMBER} echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV elif [ "${WEBAPP_RELEASE}" == "${IMAGE_VERSION}" ]; then
fi echo "**** Version ${WEBAPP_RELEASE} unchanged, checking if there is anything to build..."
if [ "${TAG_SHA}" == "${GITHUB_SHA}" ]; then
echo "**** Nothing to do, exiting build... **** "
exit 1
else else
echo "**** New version ${WEBAPP_RELEASE} found; old version was ${IMAGE_VERSION}. Generating new webapp release... ****" echo "**** Changes found... incrementing build number version... ****"
VERSION_TAG=${WEBAPP_RELEASE}-nbxyz1 NB_RELEASE_NUMBER=$((NB_RELEASE_NUMBER + 1))
VERSION_TAG=${IMAGE_VERSION}-nbxyz${NB_RELEASE_NUMBER}
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV
fi fi
else
echo "**** New version ${WEBAPP_RELEASE} found; old version was ${IMAGE_VERSION}. Generating new webapp release... ****"
VERSION_TAG=${WEBAPP_RELEASE}-nbxyz1
echo "VERSION_TAG=${VERSION_TAG}" >> $GITHUB_ENV
fi
- name: Docker meta - name: Docker meta
if: steps.version_check.outcome == 'success' && steps.version_check.conclusion == 'success' if: steps.version_check.outcome == 'success' && steps.version_check.conclusion == 'success'