forked from seek4science/seek
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DRH-132] Configure automatic Docker build.
- Loading branch information
1 parent
46f112a
commit 571e7cb
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
# 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: | ||
- digital-research-hub | ||
# 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/seek' | ||
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.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | ||
cancel-in-progress: true | ||
# Define the images/tags to build; will run in parallell | ||
strategy: | ||
matrix: | ||
include: | ||
- dockerfile: Dockerfile | ||
images: | | ||
# docker.io/scilifelabdatacentre/repo-name-backend | ||
ghcr.io/scilifelabdatacentre/seek | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
# only needed when publishing to Dockerhub | ||
# # - name: Log in to Docker Hub | ||
# 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@v2 | ||
with: | ||
registry: ghcr.io | ||
# will run as the user who triggered the action, using its token | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Docker Meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
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@v4 | ||
with: | ||
file: ${{ matrix.dockerfile }} | ||
context: . | ||
push: true | ||
# Set to wanted target, or remove if you do not use targets | ||
# target: production | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |