Skip to content

Commit

Permalink
Integrate docker images into tagged/nightly builds
Browse files Browse the repository at this point in the history
  • Loading branch information
darionhaase committed Apr 22, 2024
1 parent a672dd4 commit d7ebbe6
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/create_docker_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Create and push a Docker image for a given Git ref
name: Create & Release Docker Image

on:
workflow_call:
inputs:
git_ref:
required: true
type: string
# Uses the format of docker/metadata-action
# See https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input
image_tags:
required: true
type: string


env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.git_ref }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ inputs.image_tags }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/multiplatform.dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

7 changes: 7 additions & 0 deletions .github/workflows/nightly_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ jobs:
with:
git_ref: ${{ needs.prepare-release.outputs.tag }}
is_prerelease: true
create-docker-image:
needs: [prepare-release,create-release]
uses: ./.github/workflows/create_docker_image.yml
with:
git_ref: ${{ needs.prepare-release.outputs.tag }}
image_tags: |
type=raw,value=${{ needs.prepare-release.outputs.tag }}
15 changes: 15 additions & 0 deletions .github/workflows/tagged_release_publish_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Push Docker Image when tagged version is released

# Only do the release on proper releases (with semantic versioning tags).
on:
release:
types: [released]

jobs:
create-docker-image:
uses: ./.github/workflows/create_docker_image.yml
with:
git_ref: ${{ github.ref_name }}
# semver tag also causes creation of 'latest' tag
image_tags: |
type=semver,pattern={{version}}

0 comments on commit d7ebbe6

Please sign in to comment.