Skip to content

Publish containers #124

Publish containers

Publish containers #124

Workflow file for this run

# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions
name: Publish containers
on:
workflow_call:
inputs:
ref:
description: "Git revision (tag, commit, or branch) to build from"
required: false
type: string
default: "main"
push:
description: "Whether to push the built images to registry"
required: false
type: boolean
default: true
workflow_dispatch:
inputs:
ref:
description: "Git revision (tag, commit, or branch) to build from"
required: false
type: string
default: "main"
push:
description: "Whether to push the built images to registry"
required: false
type: boolean
default: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
devcontainer:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Set up QEMU for multi-arch builds
uses: docker/setup-qemu-action@v3
with:
# https://github.com/docker/setup-qemu-action/issues/198
# v9.2+ causes a segfault
image: tonistiigi/binfmt:qemu-v7.0.0-28
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/devcontainer
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
context: ./containers/devcontainer
file: ./containers/devcontainer/Dockerfile
push: ${{ inputs.push }}
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
build-args: |
VERSION=${{ inputs.ref }}
devenv:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Set up QEMU for multi-arch builds
uses: docker/setup-qemu-action@v3
with:
# https://github.com/docker/setup-qemu-action/issues/198
# v9.2+ causes a segfault
image: tonistiigi/binfmt:qemu-v7.0.0-28
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/devenv
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
context: ./containers/devenv
file: ./containers/devenv/Dockerfile
push: ${{ inputs.push }}
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
secrets: |
github_token=${{ secrets.GITHUB_TOKEN }}
build-args: |
VERSION=${{ inputs.ref }}