Files
slinky/.github/workflows/publish-image.yml

59 lines
1.3 KiB
YAML

name: Build and Publish Container Image
on:
push:
branches:
- main
tags:
- 'v*'
release:
types: [published]
workflow_dispatch: {}
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Derive image name (lowercase owner)
id: names
run: |
echo "OWNER_LC=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV
echo "IMAGE=${REGISTRY}/${GITHUB_REPOSITORY_OWNER,,}/slinky" >> $GITHUB_ENV
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE }}
tags: |
type=ref,event=tag
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=v1
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}