Skip to content

Merge pull request #16 from youenchene/fix-general-tab #29

Merge pull request #16 from youenchene/fix-general-tab

Merge pull request #16 from youenchene/fix-general-tab #29

name: Publish Docker image
on:
push:
branches:
- main
- master
pull_request:
types: [closed]
# Minimal permissions
permissions:
contents: read
jobs:
build-and-push:
# Run on direct pushes to default branches or when a PR is merged
if: |
github.event_name == 'push' ||
(github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker metadata (all image)
id: meta_all
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_REPOSITORY }}-all
# This will create tags like:
# latest (only on default branch)
# sha-<shortsha>
# You can add more tag strategies if you need (semver, branch, etc.)
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,format=short,prefix=sha-
- name: Build and push (all)
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta_all.outputs.tags }}
labels: ${{ steps.meta_all.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# --- WEB IMAGE ---
- name: Extract Docker metadata (web image)
id: meta_web
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_REPOSITORY }}-web
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,format=short,prefix=sha-
- name: Build and push (web)
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.web
push: true
tags: ${{ steps.meta_web.outputs.tags }}
labels: ${{ steps.meta_web.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# --- JOBS IMAGE ---
- name: Extract Docker metadata (jobs image)
id: meta_jobs
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_REPOSITORY }}-jobs
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,format=short,prefix=sha-
- name: Build and push (jobs)
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.jobs
push: true
tags: ${{ steps.meta_jobs.outputs.tags }}
labels: ${{ steps.meta_jobs.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max