Skip to content

chore: prepare v0.3.0 release #30

chore: prepare v0.3.0 release

chore: prepare v0.3.0 release #30

Workflow file for this run

name: Docker Publish
on:
push:
branches:
- main
workflow_run:
workflows:
- Release
types:
- completed
pull_request:
paths:
- "docker/**"
- ".github/workflows/docker.yml"
workflow_dispatch:
inputs:
ferrisgrid_version:
description: "Optional ferrisgrid-cli crates.io version to install, for example 0.1.0"
required: false
type: string
permissions:
contents: read
packages: write
concurrency:
group: docker-${{ github.event.workflow_run.head_branch || github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/linux-workspace
jobs:
publish:
name: Build and publish image
runs-on: ubuntu-24.04
if: github.event_name != 'workflow_run' || (github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v'))
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha || github.ref }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Resolve FerrisGrid crate version
id: ferrisgrid
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
WORKFLOW_RUN_HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
INPUT_VERSION: ${{ inputs.ferrisgrid_version }}
run: |
set -euo pipefail
version="$INPUT_VERSION"
release_tag=""
if [ -z "$version" ]; then
if [ "$EVENT_NAME" = "workflow_run" ]; then
release_tag="$WORKFLOW_RUN_HEAD_BRANCH"
elif [ "$REF_TYPE" = "tag" ]; then
release_tag="$REF_NAME"
fi
if [[ "$release_tag" == v* ]]; then
version="${release_tag#v}"
fi
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "release_tag=$release_tag" >> "$GITHUB_OUTPUT"
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=${{ steps.ferrisgrid.outputs.release_tag }},enable=${{ steps.ferrisgrid.outputs.release_tag != '' }}
- name: Build and publish
uses: docker/build-push-action@v7
with:
context: .
file: docker/linux-workspace.Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
build-args: |
FERRISGRID_VERSION=${{ steps.ferrisgrid.outputs.version }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max