Merge pull request #113 from swindonmakers/email_templates #92
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 Dev Container Base Image | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
workflow_dispatch: # Manually triggered | |
env: | |
CONTAINER_REGISTRY: ghcr.io | |
IMAGE_NAME: access-system-dev | |
BRANCH_NAME: ${{ github.head_ref || github.ref }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: π¦ Checkout code | |
uses: actions/checkout@v4 | |
- name: ποΈ Build image | |
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID},sha=${GITHUB_SHA},ref=${GITHUB_REF}" | |
- name: π Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login $CONTAINER_REGISTRY -u $ --password-stdin | |
- name: πΎ Push image | |
run: | | |
IMAGE_ID=$CONTAINER_REGISTRY/$GITHUB_REPOSITORY_OWNER/$IMAGE_NAME | |
VERSION=$(echo "${BRANCH_NAME#refs/heads/}" | sed -e 's/[^a-zA-Z0-9]/-/g') # Get the branch name from the ref and replace non-alphanumeric characters with hyphens | |
[ "$VERSION" == "master" ] && VERSION=latest | |
echo "π Image ID: $IMAGE_ID" | |
echo "#οΈβ£ GITHUB_SHA: $GITHUB_SHA" | |
echo "π― Version: $VERSION" | |
echo "π Pushing image to registry........................................." | |
docker tag $IMAGE_NAME $IMAGE_ID:$GITHUB_SHA | |
docker push $IMAGE_ID:$GITHUB_SHA | |
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION |