Skip to content

Publish Docker image #49

Publish Docker image

Publish Docker image #49

name: Publish Docker image
on:
# Schedule daily at 12am
schedule:
- cron: '0 0 * * *'
# Triggers the workflow on push events but only for the main branch
push:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
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.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
hiob/wishthis
ghcr.io/${{ github.repository }}
- name: STABLE - Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
hiob/wishthis:stable
ghcr.io/${{ github.repository }}:stable
labels: ${{ steps.meta.outputs.labels }}
build-args: WISHTHIS_GITBRANCH=stable
cache-from: type=gha,scope=stable
cache-to: type=gha,scope=stable,mode=max
- name: DEVELOP - Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
hiob/wishthis:develop
ghcr.io/${{ github.repository }}:develop
labels: ${{ steps.meta.outputs.labels }}
build-args: WISHTHIS_GITBRANCH=develop
cache-from: type=gha,scope=develop
cache-to: type=gha,scope=develop,mode=max
- name: RELEASE-CANDIDATE - Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
hiob/wishthis:release-candidate
ghcr.io/${{ github.repository }}:release-candidate
labels: ${{ steps.meta.outputs.labels }}
build-args: WISHTHIS_GITBRANCH=release-candidate
cache-from: type=gha,scope=rc
cache-to: type=gha,scope=rc,mode=max