Files
backupbot/.github/workflows/build.yml
2025-10-27 20:37:53 -07:00

78 lines
2.1 KiB
YAML

name: Build and Push Docker Image
on:
push:
branches:
- main
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# 🧠 Login to Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 🧠 Login to GitHub Container Registry
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 🧠 Login to Gitea
- name: Login to Gitea
uses: docker/login-action@v3
with:
registry: gitea.calahilstudios.com
username: ${{ github.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
gitea.calahilstudios.com/${{ github.repository }}
${{ github.repository }}
tags: |
# Always include short SHA
type=sha,format=short
# Include latest if on default branch (usually 'main' or 'develop')
type=raw,value=latest,enable={{is_default_branch}}
# If this is a semver tag (vX.X.X), add full + minor version tags
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Debug GitHub context
run: |
echo "Tags: ${{ steps.meta.outputs.tags }}"
echo "Labels: ${{ steps.meta.outputs.labels }}"
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max