78 lines
2.2 KiB
YAML
78 lines
2.2 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: Debug GitHub context
|
|
run: |
|
|
echo "Owner: ${{ github.repository_owner }}"
|
|
echo "Repo: ${{ github.event.repository.name }}"
|
|
echo "Full repo: ${{ github.repository }}"
|
|
|
|
- name: Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
ghcr.io/${{ github.repository }}
|
|
gitea.calahilstudios.com/${{ github.repository }}
|
|
${{ secrets.DOCKERHUB_USER }}/${{ 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: 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
|