Skip to content

Updated tasks

Updated tasks #16

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ "daniel-koala", "adam", "bisha" ]
pull_request:
branches: [ "daniel-koala", "adam", "bisha" ]
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v5
- name: Set image name from branch
id: image-name
run: |
declare -A BRANCH_MAP
BRANCH_MAP[daniel-koala]="code-tracking-qa"
BRANCH_MAP[adam]="code-tracking-emote"
BRANCH_MAP[bisha]="code-tracking-ai"
BRANCH="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}"
IMAGE_NAME="${BRANCH_MAP[$BRANCH]}"
if [ -z "$IMAGE_NAME" ]; then
echo "No image mapping for branch: $BRANCH"
exit 1
fi
REPO_OWNER="${{ github.repository_owner }}"
echo "image_name=${REPO_OWNER,,}/${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ steps.image-name.outputs.image_name }}
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max