Skip to content

ci: add isolated prod/dev streams with GHCR dev publishing #1

ci: add isolated prod/dev streams with GHCR dev publishing

ci: add isolated prod/dev streams with GHCR dev publishing #1

name: Build and Push Dev Docker Image (GHCR)
on:
workflow_dispatch:
push:
branches:
- dev
env:
REGISTRY: ghcr.io
IMAGE_NAME: altinity/transferia-dev
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set tag variables
id: vars
shell: bash
run: |
echo "short_sha=${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
echo "stamp=$(date -u +%Y%m%d-%H%M)" >> "$GITHUB_OUTPUT"
- 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.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=dev-latest
type=sha,prefix=dev-,format=short
type=raw,value=dev-${{ steps.vars.outputs.stamp }}-${{ steps.vars.outputs.short_sha }}
type=ref,event=branch,prefix=dev-branch-,enable=${{ github.ref_name != 'dev' }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max