67 lines
1.9 KiB
YAML
67 lines
1.9 KiB
YAML
name: Upload latest backend image to GHCR
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "backend/**"
|
|
- ".github/workflows/backend-latest.yml"
|
|
|
|
env:
|
|
IMAGE_NAME: "voyage-backend"
|
|
PYTHON_IMAGE: "python:3.13-slim"
|
|
|
|
jobs:
|
|
upload:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Set lower case owner name
|
|
id: repo_owner
|
|
run: |
|
|
LOWER_OWNER="${OWNER,,}"
|
|
echo "REPO_OWNER=${LOWER_OWNER}" >>"$GITHUB_ENV"
|
|
echo "repo_owner=${LOWER_OWNER}" >>"$GITHUB_OUTPUT"
|
|
env:
|
|
OWNER: "${{ github.repository_owner }}"
|
|
|
|
- name: Build and push latest Docker image with BuildKit cache
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./backend
|
|
platforms: linux/amd64,linux/arm64
|
|
build-args: |
|
|
PYTHON_IMAGE=${{ env.PYTHON_IMAGE }}
|
|
push: true
|
|
tags: |
|
|
ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/${{ env.IMAGE_NAME }}:latest
|
|
cache-from: |
|
|
type=registry,ref=ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/${{ env.IMAGE_NAME }}:buildcache
|
|
type=local,src=/tmp/.buildx-cache
|
|
cache-to: |
|
|
type=registry,ref=ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
|
type=local,dest=/tmp/.buildx-cache,mode=max
|
|
env:
|
|
DOCKER_BUILDKIT: 1
|