From 536943cdc67bcf725a3d58535aef6f94c05eb702 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Mon, 2 Nov 2020 12:57:23 -0600 Subject: [PATCH] Update BuildImage.yml --- .github/workflows/BuildImage.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml index b28662e..ca58270 100644 --- a/.github/workflows/BuildImage.yml +++ b/.github/workflows/BuildImage.yml @@ -15,14 +15,24 @@ jobs: - name: Build image run: | - docker build --no-cache -t ${{ github.sha }} . + # Set version + DOTNET_JSON="$(curl --retry 5 -sX GET https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json)" + DOTNET_VERSIONS="$(echo $DOTNET_JSON | jq -r '."releases-index"[] | select(."support-phase"=="lts") | ."latest-sdk"' | tr '\n' ' ' | head -c -1)" + DOTNET_TAG="$(echo $DOTNET_VERSIONS | tr ' ' '_')" + echo "DOTNET_TAG=${{ secrets.DOTNET_TAG }}" >> $GITHUB_ENV + # Build image + docker build --no-cache --build-arg DOTNET_VERSIONS="${DOTNET_VERSIONS}" -t ${{ github.sha }} . - name: Tag image if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }} run: | docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME} + docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} + docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME} + docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} + docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} - name: Credential check @@ -47,6 +57,8 @@ jobs: - name: Push tags to GitHub Container Registry if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.CR_USER && env.CR_PAT }} run: | + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} + docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME} @@ -58,5 +70,7 @@ jobs: - name: Push tags to DockerHub if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.DOCKERUSER && env.DOCKERPASS }} run: | + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }} + docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ env.DOTNET_TAG }}-${{ github.sha }} docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }} docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}