Skip to content

Commit

Permalink
Merge pull request #883 from ScilifelabDataCentre/develop
Browse files Browse the repository at this point in the history
update github workflow
  • Loading branch information
senthil10 authored Sep 28, 2022
2 parents 6ad91e4 + 50c7cef commit 33718bf
Showing 1 changed file with 51 additions and 13 deletions.
64 changes: 51 additions & 13 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,76 @@
---
name: Publish Docker image
# Build and publish docker image(s)
# Publishing to Dockerhub requires a username and token
# as the secrets DOCKERHUB_USERNAME and DOCKERHUB_TOKEN
# remember to change repo-name and set dockerfile(s)/image name(s) in the matrix

name: Publish Docker Image
on:
# generate image whenever there is a push to the listed branches
push:
branches:
- main
- develop
- develop2
# generate images for releases, using the tag name
# the newest one will be latest as well
release:
types: [published]
jobs:
push_to_registry:
# only generate images when in the named repo
# (to avoid running the action in forks)
if: github.repository == 'ScilifelabDataCentre/covid-portal'
name: Push Docker image to Docker Hub
name: Publish Docker Image
runs-on: ubuntu-latest
# Cancel earlier job if there is a new one for the same branch/release
concurrency:
group: ${{ github.ref }}-docker-build
cancel-in-progress: true
# Define the images/tags to build; will run in parallell
strategy:
matrix:
include:
- dockerfile: Dockerfiles/Dockerfile
images: |
docker.io/scilifelabdatacentre/covid-portal
ghcr.io/scilifelabdatacentre/covid-portal
permissions:
contents: read
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3
# only needed when publishing to Dockerhub
- name: Log in to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
# available in scilifelabdatacentre, ask admin for help
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# only needed when publishing to Github (ghcr.io)
- name: Log in to Github Container Repository
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
# will run as the user who triggered the action, using its token
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: docker-tag
uses: yuya-takeyama/docker-tag-from-github-ref-action@v1
- name: Push backend to Docker Hub
uses: docker/build-push-action@v2
- name: Docker Meta
id: meta
uses: docker/metadata-action@v4
with:
file: Dockerfiles/Dockerfile
images: ${{ matrix.images }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and Publish
uses: docker/build-push-action@v3
with:
file: ${{ matrix.dockerfile }}
context: .
push: true
tags: |
scilifelabdatacentre/covid-portal:${{ steps.docker-tag.outputs.tag }}
ghcr.io/scilifelabdatacentre/covid-portal:${{ steps.docker-tag.outputs.tag }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 33718bf

Please sign in to comment.