Build Docker image and push to GHCR #15
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: 🏗️ | |
on: # yamllint disable-line rule:truthy | |
pull_request: | |
push: | |
branches: ["release/*", "unstable/*"] | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: Docker image tag | |
required: true | |
type: string | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build Docker image | |
run: | | |
IMAGE="ghcr.io/$GITHUB_REPOSITORY:${DOCKER_TAG/'/'/'-'}" | |
echo "IMAGE=$IMAGE" >>"$GITHUB_ENV" | |
docker build . \ | |
--build-arg BUILDKIT_INLINE_CACHE=1 \ | |
--cache-from $IMAGE \ | |
--tag $IMAGE | |
env: | |
DOCKER_TAG: ${{ inputs.tag || github.ref_name }} | |
- name: Log in to GHCR | |
if: github.event_name != 'pull_request' | |
run: >- | |
echo ${{ secrets.GITHUB_TOKEN }} | | |
docker login ghcr.io -u $GITHUB_ACTOR --password-stdin | |
- name: Push Docker image to GHCR | |
if: github.event_name != 'pull_request' | |
run: docker push $IMAGE |