Skip to content

Merge pull request #41 from MuNuChapterHKN/develop #57

Merge pull request #41 from MuNuChapterHKN/develop

Merge pull request #41 from MuNuChapterHKN/develop #57

Workflow file for this run

name: Docker Image CI
on:
push:
branches:
- main
- develop
tags:
- '*'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
DOCKER_IMAGE=ghcr.io/$OWNER/hkn-website
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
TAGS="$DOCKER_IMAGE:$VERSION,$DOCKER_IMAGE:latest"
elif [[ $GITHUB_REF == refs/heads/main ]]; then
VERSION=main-$(git rev-parse --short ${{ github.sha }})
TAGS="$DOCKER_IMAGE:$VERSION,$DOCKER_IMAGE:latest"
elif [[ $GITHUB_REF == refs/heads/develop ]]; then
VERSION=dev-$(git rev-parse --short ${{ github.sha }})
TAGS="$DOCKER_IMAGE:$VERSION,$DOCKER_IMAGE:test"
else
VERSION=$(git rev-parse --short ${{ github.sha }})
TAGS="$DOCKER_IMAGE:$VERSION"
fi
echo ::set-output name=version::$VERSION
echo ::set-output name=tags::$TAGS
shell: bash
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.prep.outputs.tags }}