Skip to content

Merge pull request #90 from swindonmakers/castaway/43_door_pending_fix #27

Merge pull request #90 from swindonmakers/castaway/43_door_pending_fix

Merge pull request #90 from swindonmakers/castaway/43_door_pending_fix #27

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