2024-04-16 03:02:03 -04:00
|
|
|
---
|
|
|
|
|
|
|
|
name: 🏗️
|
|
|
|
|
|
|
|
on: # yamllint disable-line rule:truthy
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches: ["release/*", "unstable/*"]
|
2024-05-27 14:39:55 -04:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
tag:
|
2024-09-14 14:05:40 -04:00
|
|
|
description: Docker image tag
|
|
|
|
required: true
|
2024-05-27 14:39:55 -04:00
|
|
|
type: string
|
2024-04-16 03:02:03 -04:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build-and-push:
|
|
|
|
runs-on: ubuntu-latest
|
2024-04-18 22:01:29 -04:00
|
|
|
timeout-minutes: 10
|
2024-04-16 03:02:03 -04:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build Docker image
|
|
|
|
run: |
|
2024-09-07 14:28:31 -04:00
|
|
|
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}"
|
2024-04-16 03:02:03 -04:00
|
|
|
echo "IMAGE=$IMAGE" >>"$GITHUB_ENV"
|
2024-09-07 14:28:31 -04:00
|
|
|
echo "IMAGE_MAJOR=$IMAGE_MAJOR" >>"$GITHUB_ENV"
|
|
|
|
echo "IMAGE_MAJOR_MINOR=$IMAGE_MAJOR_MINOR" >>"$GITHUB_ENV"
|
2024-04-16 03:02:03 -04:00
|
|
|
docker build . \
|
|
|
|
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
|
|
|
--cache-from $IMAGE \
|
|
|
|
--tag $IMAGE
|
2024-09-07 14:28:31 -04:00
|
|
|
docker tag $IMAGE $IMAGE_MAJOR
|
|
|
|
docker tag $IMAGE $IMAGE_MAJOR_MINOR
|
2024-05-27 14:39:55 -04:00
|
|
|
env:
|
|
|
|
DOCKER_TAG: ${{ inputs.tag || github.ref_name }}
|
2024-04-26 19:08:30 -04:00
|
|
|
- name: Log in to GHCR
|
2024-04-16 03:02:03 -04:00
|
|
|
if: github.event_name != 'pull_request'
|
2024-05-27 14:00:48 -04:00
|
|
|
run: >-
|
2024-04-16 03:02:03 -04:00
|
|
|
echo ${{ secrets.GITHUB_TOKEN }} |
|
|
|
|
docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
|
2024-04-26 19:08:30 -04:00
|
|
|
- name: Push Docker image to GHCR
|
|
|
|
if: github.event_name != 'pull_request'
|
2024-09-07 14:28:31 -04:00
|
|
|
run: |
|
|
|
|
docker push $IMAGE
|
|
|
|
docker push $IMAGE_MAJOR
|
|
|
|
docker push $IMAGE_MAJOR_MINOR
|