Skip to content

Commit

Permalink
[Bugfix] Docker image builds (#739)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjustesen authored Sep 7, 2023
1 parent ea5388f commit 6f70bad
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 38 deletions.
37 changes: 21 additions & 16 deletions .github/workflows/cd-docker-hub.yml → .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Build and push Docker image to Docker Hub
name: Build and push Docker images

on:
# release:
# types: [ published ]
push:
tags:
- 'v*'
workflow_dispatch:
release:
branches: [ main ]
types: [ published ]

env:
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7

jobs:
build_and_push_image:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
Expand All @@ -38,6 +34,13 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: docker-image-to-lowercase
name: Convert Docker image to lower case
run: echo "DOCKER_IMAGE=$(echo ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
Expand All @@ -46,12 +49,14 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_IMAGE }}
images: |
${{ env.DOCKER_IMAGE }}
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
latest
type=semver,pattern={{major}}.{{minor}}
- name: Build and push image to Docker Hub
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
Expand Down
44 changes: 24 additions & 20 deletions .github/workflows/cd-ghcr.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Build and push Docker image to GHCR
name: Build and test Docker images

on:
push:
branches:
- 'release-**'
workflow_dispatch:
release:
branches: [ main ]
types: [ published ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7

jobs:
build_and_push_image:
build_and_test_images:
runs-on: ubuntu-22.04
permissions:
contents: read
Expand All @@ -37,24 +26,39 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: docker-image-to-lowercase
name: Convert Docker image to lower case
run: echo "DOCKER_IMAGE=$(echo ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: |
${{ env.DOCKER_IMAGE }}
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push image to GHCR
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
push: true
push: false
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Test

on:
- push
- workflow_dispatch
push:
workflow_dispatch:

jobs:
test:
strategy:
Expand Down

0 comments on commit 6f70bad

Please sign in to comment.