Skip to content

Commit

Permalink
Merge pull request #58 from Amsterdam/refactor-github-action-build-an…
Browse files Browse the repository at this point in the history
…d-push

Refactored the github action that builds and pushes the docker image to docker hub
  • Loading branch information
vanbuiten authored Apr 16, 2024
2 parents aaa0653 + c580427 commit 1d4b119
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 91 deletions.
91 changes: 0 additions & 91 deletions .github/workflows/build_and_push_ghcr.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/build_and_push_to_docker_hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build Docker image and push to Docker Hub

on:
push:
branches: [ 'main' ]
tags: [ '*.*.*' ]

jobs:
build:
name: Build a new Docker image for the release (and a latest) and push it to Docker Hub
runs-on: ubuntu-latest

steps:
# https://github.com/actions/checkout
- name: Checkout repository
uses: actions/checkout@v4

# https://github.com/docker/login-action
- name: Log into Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

# https://github.com/docker/metadata-action
- name: Extract Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: docker.io/${{ secrets.DOCKERHUB_IMAGE_NAME }}

# https://github.com/docker/build-push-action
- name: Build and push Docker image
if: github.event_name != 'pull_request'
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 1d4b119

Please sign in to comment.