Commit ded103b4 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

build: External labels

parent 982c9786
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -56,10 +56,13 @@ jobs:
        id: build
        run: |

          DIRECTORY="."
          PLATFORMS="linux/amd64,linux/arm64"
          VERSION="${{ vars.MAJOR }}.${{ vars.MINOR }}"
          echo "version=${VERSION}" >> $GITHUB_OUTPUT
          BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
          TITLE=$(grep --only-matching --perl-regex "(?<=image.title\=).*" $DIRECTORY/Dockerfile)
          DESC=$(grep --only-matching --perl-regex "(?<=image.description\=).*" $DIRECTORY/Dockerfile)
   
          TAGS=()
          TAGS=("${{ secrets.DOCKERHUB_REPO }}:latest")
@@ -67,14 +70,26 @@ jobs:
          TAGS+=("ghcr.io/${{ github.repository }}:latest")
          TAGS+=("ghcr.io/${{ github.repository }}:${VERSION}")
          
          LABELS=()
          LABELS=("org.opencontainers.image.licenses=\"MIT\"")
          LABELS+=("org.opencontainers.image.title=${TITLE}")
          LABELS+=("org.opencontainers.image.description=${DESC}")
          LABELS+=("org.opencontainers.image.version=\"${VERSION}\"")
          LABELS+=("org.opencontainers.image.created=\"${BUILD_DATE}\"")
          LABELS+=("org.opencontainers.image.revision=\"${GITHUB_RUN_ID}\"")
          LABELS+=("org.opencontainers.image.url=\"https://hub.docker.com/r/${{ secrets.DOCKERHUB_REPO }}/\"")
          LABELS+=("org.opencontainers.image.source=\"https://github.com/${{ github.repository }}/\"")

          docker buildx build --platform ${PLATFORMS} \
            --output "type=image,push=true" \
            --output "type=image,push=false" \
            --progress=plain \
            --build-arg "BUILD_ARG=${GITHUB_RUN_ID}" \
            --build-arg "VERSION_ARG=${VERSION}" \
            --build-arg "DATE_ARG=${BUILD_DATE}" \
            --build-arg "VCS_REF=${GITHUB_SHA::8}" \
            $(printf "%s" "${TAGS[@]/#/ --tag }" ) .
            $(printf "%s" "${LABELS[@]/#/ --label }" ) \
            $(printf "%s" "${TAGS[@]/#/ --tag }" ) $DIRECTORY
            
            rm -f ${HOME}/.docker/config.json
            jdksks
      -
        name: Create a release
        uses: action-pack/github-release@v2