54 lines
1.7 KiB
YAML
54 lines
1.7 KiB
YAML
name: Build and Push Docker Image
|
|
run-name: Build triggered by ${{ gitea.actor }}
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-22.04 # Using specific Ubuntu version instead of latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
driver: docker-container
|
|
platforms: linux/amd64 # Target standard PC architecture
|
|
install: true
|
|
|
|
- name: Log in to private registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: registry.acayip.dev
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Generate image tag
|
|
id: meta
|
|
run: |
|
|
VERSION=$(date +%Y%m%d)-$(git rev-parse --short HEAD)
|
|
echo "TAG=registry.acayip.dev/log101-dot-dev:${VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64 # Explicitly specify target architecture
|
|
push: ${{ gitea.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.TAG }}
|
|
# Add build caching for faster builds
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
# Add labels for better tracking
|
|
labels: |
|
|
org.opencontainers.image.source=${{ gitea.repository }}
|
|
org.opencontainers.image.revision=${{ gitea.sha }}
|
|
org.opencontainers.image.created=${{ gitea.event.created_at }}
|