Build and push both docker images to the GitHub Container Registry #26
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
name: Build and push both docker images to the GitHub Container Registry | |
on: | |
push: | |
# Branch to be used in development, builds images tagged as "dev" | |
branches: | |
- main | |
paths-ignore: | |
- 'README.md' | |
# Triggered when a release is published - builds images tagged as "prod" | |
release: | |
types: [published] | |
# workflow_dispatch can be used on feature branch to test the site on dev instance | |
# Or fix a bug on a release branch | |
workflow_dispatch: | |
inputs: | |
docker_tag: | |
description: 'Docker tag for the image, default is dev. Use prod for a release branch fix' | |
required: false | |
default: 'dev' | |
jobs: | |
push-to-container-registry: | |
if: github.repository == 'ScilifelabDataCentre/genome-portal' | |
name: Build and push both images to the GitHub Container Registry | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
defaults: | |
run: | |
working-directory: ./scripts/ci | |
strategy: | |
matrix: | |
include: | |
- dockerfile: hugo.dockerfile | |
image_name: swg-hugo-site | |
- dockerfile: data.dockerfile | |
image_name: swg-data-builder | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Docker tag | |
id: set-tag | |
run: | | |
./set_docker_tag ${{ github.event_name }} \ | |
${{ github.event.inputs.docker_tag }} \ | |
>> $GITHUB_OUTPUT | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
push: ${{ github.event_name != 'pull_request' }} | |
context: . | |
file: ./docker/${{ matrix.dockerfile }} | |
tags: ghcr.io/scilifelabdatacentre/${{ matrix.image_name }}:${{ steps.set-tag.outputs.tag }} | |
build-args: | | |
HUGO_GIT_REF_NAME=${{ github.ref_name }} | |
HUGO_GIT_SHA=${{ github.sha }} |