Skip to content

design, cleanup, domain config #18

design, cleanup, domain config

design, cleanup, domain config #18

name: Docker CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
name: "Docker Build and/or Deploy"
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
permissions:
contents: read
packages: write
strategy:
matrix:
image: [ "tutor-assistant", "tutor-assistant-app-service", "tutor-assistant-web" ]
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker build ${{ matrix.image }} --file ${{ matrix.image }}/Dockerfile --tag ${{ matrix.image }}
- name: Log into Registry
if: ${{ github.event_name == 'push' }}
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
- name: Push Image
if: ${{ github.event_name == 'push' }}
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag ${{ matrix.image }} $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION