Skip to content

Commit

Permalink
Merge pull request #57 from sanger-pathogens/feature/publish-on-release
Browse files Browse the repository at this point in the history
Add GH Action to Publish on Release
  • Loading branch information
HarryHung authored Nov 2, 2023
2 parents 8639a1a + 45718cb commit 1342051
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/docker-image-build-to-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ on:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_call:

jobs:

build:

build-to-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4

- name: Build the Docker image to test
run: docker build . --file Dockerfile --tag bentley-app:$(date +%s) --target builder
54 changes: 54 additions & 0 deletions .github/workflows/docker-image-publish-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Docker Image Publish on Release

on:
release:
types: [published]

jobs:
build-to-test:
uses: ./.github/workflows/docker-image-build-to-test.yml

build-and-push-image:
needs: build-to-test

runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- 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: |
${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
target: app
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 1342051

Please sign in to comment.