Skip to content

Commit

Permalink
Publish release to both docker registries
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Ott <[email protected]>
  • Loading branch information
DerOetzi committed Jul 17, 2023
1 parent b1d8ce3 commit 21d6a77
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions .github/workflows/build_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
types: [published]

env:
REGISTRY: ghcr.io
REGISTRY_GITHUB: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
Expand Down Expand Up @@ -144,26 +144,45 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@master

- name: Log in to the Container registry
- name: Log in to the Docker github container registry
if: ${{github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main')}}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
registry: ${{ env.REGISTRY_GITHUB }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
- name: Log in to the Docker container registry
if: ${{github.event_name == 'release'}}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker (No Release)
id: meta
if: ${{github.event_name != 'release'}}
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY_GITHUB }}/${{ env.IMAGE_NAME }}
- name: Extract metadata (tags, labels) for Docker (Release)
id: meta_release
if: ${{github.event_name == 'release'}}
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: |
${{ env.IMAGE_NAME }}
${{ env.REGISTRY_GITHUB }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
context: docker
push: ${{github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main')}}
tags: ${{ steps.meta.outputs.tags }}
tags: ${{github.event_name == 'release' && steps.meta_release.outputs.tags || steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


0 comments on commit 21d6a77

Please sign in to comment.