Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
5c2804327This file is pinned to the selected release. Download the original to open it in your design tool.
name: Build backend Docker image
on:
push:
branches: [main, "claude/**","feature/**"]
paths:
- "server/**"
- ".github/workflows/backend-image.yml"
workflow_dispatch:
permissions:
contents: read
packages: write
env:
IMAGE_NAME: ghcr.io/macnite/hivehub
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Compute image tags
run: |
echo "SHORT_SHA=${GITHUB_SHA::7}" >> "$GITHUB_ENV"
# Branch name as a Docker-safe tag (claude/foo-bar -> claude-foo-bar),
# so each branch build is pullable without clobbering another's image.
echo "BRANCH_TAG=$(echo "$GITHUB_REF_NAME" | tr '/' '-')" >> "$GITHUB_ENV"
# Only main updates the :latest tag the docker-compose deployment pulls.
# A feature / claude branch build must never overwrite it.
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
echo "LATEST_TAG=${IMAGE_NAME}:latest" >> "$GITHUB_ENV"
else
echo "LATEST_TAG=" >> "$GITHUB_ENV"
fi
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push backend image
uses: docker/build-push-action@v6
with:
context: ./server
file: ./server/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ github.sha }}
${{ env.IMAGE_NAME }}:sha-${{ env.SHORT_SHA }}
${{ env.IMAGE_NAME }}:${{ env.BRANCH_TAG }}
${{ env.LATEST_TAG }}