Add Docker tags for major and minor versions
This commit is contained in:
parent
153ccde9bc
commit
cfb9d93a26
|
@ -9,8 +9,8 @@ on: # yamllint disable-line rule:truthy
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
tag:
|
||||||
description: Docker image tag
|
description: Docker image tag (optional, defaults to Git ref)
|
||||||
required: true
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -21,12 +21,21 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
run: |
|
run: |
|
||||||
IMAGE="ghcr.io/$GITHUB_REPOSITORY:${DOCKER_TAG/'/'/'-'}"
|
DOCKER_TAG="${DOCKER_TAG/'/'/'-'}"
|
||||||
|
DOCKER_TAG_MAJOR=$(echo "$DOCKER_TAG" | cut -d '.' -f 1)
|
||||||
|
DOCKER_TAG_MAJOR_MINOR=$(echo "$DOCKER_TAG" | cut -d '.' -f 1-2)
|
||||||
|
IMAGE="ghcr.io/$GITHUB_REPOSITORY:${DOCKER_TAG}"
|
||||||
|
IMAGE_MAJOR="ghcr.io/$GITHUB_REPOSITORY:${DOCKER_TAG_MAJOR}"
|
||||||
|
IMAGE_MAJOR_MINOR="ghcr.io/$GITHUB_REPOSITORY:${DOCKER_TAG_MAJOR_MINOR}"
|
||||||
echo "IMAGE=$IMAGE" >>"$GITHUB_ENV"
|
echo "IMAGE=$IMAGE" >>"$GITHUB_ENV"
|
||||||
|
echo "IMAGE_MAJOR=$IMAGE_MAJOR" >>"$GITHUB_ENV"
|
||||||
|
echo "IMAGE_MAJOR_MINOR=$IMAGE_MAJOR_MINOR" >>"$GITHUB_ENV"
|
||||||
docker build . \
|
docker build . \
|
||||||
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
||||||
--cache-from $IMAGE \
|
--cache-from $IMAGE \
|
||||||
--tag $IMAGE
|
--tag $IMAGE
|
||||||
|
docker tag $IMAGE $IMAGE_MAJOR
|
||||||
|
docker tag $IMAGE $IMAGE_MAJOR_MINOR
|
||||||
env:
|
env:
|
||||||
DOCKER_TAG: ${{ inputs.tag || github.ref_name }}
|
DOCKER_TAG: ${{ inputs.tag || github.ref_name }}
|
||||||
- name: Log in to GHCR
|
- name: Log in to GHCR
|
||||||
|
@ -36,4 +45,7 @@ jobs:
|
||||||
docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
|
docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
|
||||||
- name: Push Docker image to GHCR
|
- name: Push Docker image to GHCR
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
run: docker push $IMAGE
|
run: |
|
||||||
|
docker push $IMAGE
|
||||||
|
docker push $IMAGE_MAJOR
|
||||||
|
docker push $IMAGE_MAJOR_MINOR
|
||||||
|
|
Loading…
Reference in New Issue