Skip to content

Version Packages (#296) #19

Version Packages (#296)

Version Packages (#296) #19

Workflow file for this run

name: Publish Docker image
# First run creates the GHCR package. Before publishing the Railway marketplace
# template, confirm the package visibility is Public in GitHub Packages.
on:
push:
branches: [main]
tags:
- 'cycling-coach@*'
workflow_dispatch:
permissions:
contents: read
packages: write
env:
IMAGE_NAME: ghcr.io/yerzhansa/cycling-coach
jobs:
image:
runs-on: ubuntu-latest
timeout-minutes: 30
concurrency:
group: publish-image-${{ github.ref }}
cancel-in-progress: false
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
name: Derive image tags
shell: bash
run: |
set -euo pipefail
short_sha="${GITHUB_SHA::12}"
version=""
if [[ "${GITHUB_REF_TYPE}" == "tag" && "${GITHUB_REF_NAME}" == cycling-coach@* ]]; then
version="${GITHUB_REF_NAME#cycling-coach@}"
fi
{
echo "tags<<EOF"
echo "${IMAGE_NAME}:stable"
echo "${IMAGE_NAME}:main-${short_sha}"
if [[ -n "$version" ]]; then
echo "${IMAGE_NAME}:${version}"
fi
echo "EOF"
} >> "$GITHUB_OUTPUT"
{
echo "labels<<EOF"
echo "org.opencontainers.image.title=Cycling Coach"
echo "org.opencontainers.image.description=Single-tenant AI cycling coach for Telegram and intervals.icu"
echo "org.opencontainers.image.source=https://github.com/yerzhansa/cycling-coach"
echo "org.opencontainers.image.revision=${GITHUB_SHA}"
if [[ -n "$version" ]]; then
echo "org.opencontainers.image.version=${version}"
fi
echo "EOF"
} >> "$GITHUB_OUTPUT"
- uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: .
file: packages/cycling-coach/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}