Skip to content

Container

Container #1175

name: Container
on:
workflow_run:
workflows: [ "CI (Podman Devcontainer)", Releaser ]
types:
- completed
workflow_dispatch:
jobs:
prepare-checkout:
# run on: manual dispatch, successful Releaser, or successful CI on main
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
(github.event.workflow_run.name == 'Releaser' ||
github.event.workflow_run.head_branch == 'main'))
name: Prepare ref
runs-on: ubuntu-latest
outputs:
checkout-ref: ${{ steps.ref.outputs.checkout-ref }}
tag: ${{ steps.ref.outputs.tag }}
steps:
- name: Get Ref from releaser
id: releaser
if: github.event.workflow_run.name == 'Releaser'
uses: ipdxco/unified-github-workflows/.github/actions/inspect-releaser@v0.0
with:
artifacts-url: ${{ github.event.workflow_run.artifacts_url }}
- name: Resolve ref
id: ref
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "checkout-ref=${{ github.sha }}" >> "$GITHUB_OUTPUT"
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event.workflow_run.name }}" = "Releaser" ]; then
echo "checkout-ref=${{ steps.releaser.outputs.version }}" >> "$GITHUB_OUTPUT"
echo "tag=${{ steps.releaser.outputs.version }}" >> "$GITHUB_OUTPUT"
else
echo "checkout-ref=${{ github.event.workflow_run.head_sha }}" >> "$GITHUB_OUTPUT"
echo "tag=${{ github.event.workflow_run.head_branch }}" >> "$GITHUB_OUTPUT"
fi
publish:
name: Publish
needs: [ prepare-checkout ]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare-checkout.outputs.checkout-ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{raw}},value=${{ needs.prepare-checkout.outputs.tag }}
type=raw,value=${{ needs.prepare-checkout.outputs.tag }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64