Files
healthchecks-bulk-editor/.gitea/workflows/dockerhub-build-push.yml
estebanthi 5dd900f4fd
All checks were successful
Build and Push Docker Image / build-push (push) Successful in 50s
Dockerization
2025-10-20 13:28:28 +02:00

80 lines
2.5 KiB
YAML

name: Build and Push Docker Image
on:
push:
branches:
- 'main'
env:
REGISTRY_USER: ${{ secrets.DOCKERHUB_USER }}
REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.CI_GITEA_TOKEN }} # Required for Docker metadata extraction
IMAGE_NAME: "estebanthi/hc-bulk"
# CACHE_REF: ${{ env.REGISTRY_HOST }}/${{ env.IMAGE_NAME }}:buildcache # (Optional) for build cache
jobs:
build-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
# (Optional) checks if current branch is the default branch
- name: Define branch helpers
id: branch
run: |
DEFAULT="${{ github.event.repository.default_branch }}"
CURRENT="${{ github.ref_name }}"
if [ "$DEFAULT" = "$CURRENT" ]; then
echo "is_default_branch=true" >> $GITHUB_OUTPUT
else
echo "is_default_branch=false" >> $GITHUB_OUTPUT
fi
# (Optional) automatically extract tags and labels from git context
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
github-token: ${{ env.GITHUB_TOKEN }}
images: ${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha
type=raw,value=latest,enable=${{ steps.branch.outputs.is_default_branch }}
# (Optional) for multi-platform builds
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# (Optional but recommended) for advanced builds
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to registry
uses: docker/login-action@v3
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with: # Adjust as needed
context: .
file: ./Dockerfile
push: true
# platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=registry,ref=${{ env.CACHE_REF }}
# cache-to: type=registry,ref=${{ env.CACHE_REF }},mode=max
- name: Image details
run: |
echo "Image pushed: ${{ env.IMAGE_NAME }}"
echo "Labels: ${{ steps.meta.outputs.labels }}"
echo "Tags: ${{ steps.meta.outputs.tags }}"
echo "Digest: ${{ steps.meta.outputs.digest }}"