Skip to content

Commit 6168a0b

Browse files
Merge pull request #3 from rdrake/feature/ci-bisha
Add Docker image workflow
2 parents 2b8c759 + aec58e6 commit 6168a0b

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/docker-image.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "daniel-koala", "adam", "bisha" ]
6+
pull_request:
7+
branches: [ "daniel-koala", "adam", "bisha" ]
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
steps:
21+
- uses: actions/checkout@v5
22+
23+
- name: Set image name from branch
24+
id: image-name
25+
run: |
26+
declare -A BRANCH_MAP
27+
BRANCH_MAP[daniel-koala]="code-tracking-qa"
28+
BRANCH_MAP[adam]="code-tracking-emote"
29+
BRANCH_MAP[bisha]="code-tracking-ai"
30+
31+
BRANCH="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}"
32+
IMAGE_NAME="${BRANCH_MAP[$BRANCH]}"
33+
34+
if [ -z "$IMAGE_NAME" ]; then
35+
echo "No image mapping for branch: $BRANCH"
36+
exit 1
37+
fi
38+
39+
REPO_OWNER="${{ github.repository_owner }}"
40+
echo "image_name=${REPO_OWNER,,}/${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
41+
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v3
44+
45+
- name: Log in to GitHub Container Registry
46+
uses: docker/login-action@v3
47+
with:
48+
registry: ${{ env.REGISTRY }}
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Extract metadata for Docker
53+
id: meta
54+
uses: docker/metadata-action@v5
55+
with:
56+
images: ${{ env.REGISTRY }}/${{ steps.image-name.outputs.image_name }}
57+
tags: |
58+
type=sha
59+
type=ref,event=branch
60+
type=ref,event=pr
61+
type=raw,value=latest
62+
63+
- name: Build and push Docker image
64+
uses: docker/build-push-action@v6
65+
with:
66+
context: .
67+
file: ./Dockerfile
68+
push: ${{ github.event_name != 'pull_request' }}
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}
71+
cache-from: type=gha
72+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)