v0.4.2 #46
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: CD container | |
on: | |
release: | |
types: [ created ] | |
workflow_dispatch: | |
inputs: | |
tag_name: | |
required: true | |
description: E.g. "v0.3.0" | |
concurrency: | |
group: container/${{ github.event.inputs.tag_name || github.event.release.tag_name }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
build-and-push-container: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Resolve variables | |
id: variables | |
run: echo "tag_name=${{ github.event.inputs.tag_name || github.event.release.tag_name }}" >> "$GITHUB_OUTPUT" | |
- uses: actions/checkout@v3 | |
- name: Download artifact | |
run: gh release download ${{ steps.variables.outputs.tag_name }} --pattern "*+linux+x86-64.tar.xz" && ls -lha | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Unpack downloaded artifact | |
run: tar xJf deliverymetrics-${{ steps.variables.outputs.tag_name }}+linux+x86-64.tar.xz && ls -lha | |
- name: Log in to github pkgs | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- uses: docker/metadata-action@v4 | |
id: meta | |
with: | |
images: ghcr.io/${{ github.repository }} | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern=v{{version}} | |
type=semver,pattern=v{{major}}.{{minor}} | |
type=semver,pattern=v{{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} | |
type=raw,value=latest | |
type=sha | |
- uses: docker/setup-qemu-action@v2 | |
- uses: docker/setup-buildx-action@v2 | |
- name: Build & push image | |
run: | | |
for x in $(echo "${{ steps.meta.outputs.tags}}" | tr '\n' ' '); do tags="$tags --tag $x"; done && echo "tags: $tags" | |
for x in $(echo "${{ steps.meta.outputs.labels}}" | tr '\n' ' '); do labels="$labels --label $x"; done && echo "labels: $labels" | |
docker buildx build \ | |
--push \ | |
$tags \ | |
$labels \ | |
--platform linux/amd64,linux/arm64 \ | |
--file Dockerfile \ | |
. | |
- name: Smoke test container | |
run: | | |
docker pull ghcr.io/${{ github.repository }}:${{ steps.variables.outputs.tag_name }} | |
docker run --rm -i ghcr.io/${{ github.repository }}:${{ steps.variables.outputs.tag_name }} --help |