build: External labels
This commit is contained in:
parent
982c97861c
commit
ded103b403
1 changed files with 20 additions and 5 deletions
25
.github/workflows/build.yml
vendored
25
.github/workflows/build.yml
vendored
|
@ -55,26 +55,41 @@ jobs:
|
|||
name: Build Docker image
|
||||
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")
|
||||
TAGS+=("${{ secrets.DOCKERHUB_REPO }}:${VERSION}")
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue