Skip to content

Added github actions #1

Added github actions

Added github actions #1

Workflow file for this run

name: Release Multi-Arch Images
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Release tag to publish (for example: v1.2.3)"
required: false
type: string
permissions:
contents: read
packages: write
jobs:
resolve:
name: Resolve Release Context
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.vars.outputs.release_tag }}
image_base: ${{ steps.vars.outputs.image_base }}
steps:
- name: Resolve tag and image base
id: vars
shell: bash
run: |
set -euo pipefail
repo_lc="$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
echo "image_base=ghcr.io/${repo_lc}" >> "$GITHUB_OUTPUT"
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
tag="${GITHUB_REF_NAME}"
else
tag="${{ github.event.inputs.tag }}"
if [[ -z "$tag" && "${GITHUB_REF_TYPE}" == "tag" ]]; then
tag="${GITHUB_REF_NAME}"
fi
fi
if [[ ! "$tag" =~ ^v.+$ ]]; then
echo "Workflow requires a tag in v* format."
echo "Provide workflow_dispatch input 'tag' or run from a v* tag ref."
exit 1
fi
echo "release_tag=${tag}" >> "$GITHUB_OUTPUT"
backend:
name: Build Backend Image
runs-on: ubuntu-latest
needs: resolve
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.resolve.outputs.release_tag }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push backend
uses: docker/build-push-action@v6
with:
context: .
file: backend/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ needs.resolve.outputs.image_base }}-backend:${{ needs.resolve.outputs.release_tag }}
${{ needs.resolve.outputs.image_base }}-backend:latest
frontend:
name: Build Frontend Image
runs-on: ubuntu-latest
needs: resolve
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.resolve.outputs.release_tag }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push frontend
uses: docker/build-push-action@v6
with:
context: frontend
file: frontend/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ needs.resolve.outputs.image_base }}-frontend:${{ needs.resolve.outputs.release_tag }}
${{ needs.resolve.outputs.image_base }}-frontend:latest