Skip to content

Commit 56c553a

Browse files
clucraftclaude
andcommitted
Add GitHub Actions workflow for Docker builds
Builds and pushes images to GitHub Container Registry: - ghcr.io/clucraft/priceghost-backend - ghcr.io/clucraft/priceghost-frontend Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 10660e5 commit 56c553a

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

.github/workflows/docker-build.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Build and Push Docker Images
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
BACKEND_IMAGE: ghcr.io/${{ github.repository_owner }}/priceghost-backend
13+
FRONTEND_IMAGE: ghcr.io/${{ github.repository_owner }}/priceghost-frontend
14+
15+
jobs:
16+
build-backend:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Log in to GitHub Container Registry
30+
if: github.event_name != 'pull_request'
31+
uses: docker/login-action@v3
32+
with:
33+
registry: ${{ env.REGISTRY }}
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Extract metadata for Backend
38+
id: meta
39+
uses: docker/metadata-action@v5
40+
with:
41+
images: ${{ env.BACKEND_IMAGE }}
42+
tags: |
43+
type=ref,event=branch
44+
type=sha,prefix=
45+
type=raw,value=latest,enable={{is_default_branch}}
46+
47+
- name: Build and push Backend image
48+
uses: docker/build-push-action@v5
49+
with:
50+
context: ./backend
51+
push: ${{ github.event_name != 'pull_request' }}
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max
56+
57+
build-frontend:
58+
runs-on: ubuntu-latest
59+
permissions:
60+
contents: read
61+
packages: write
62+
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@v4
66+
67+
- name: Set up Docker Buildx
68+
uses: docker/setup-buildx-action@v3
69+
70+
- name: Log in to GitHub Container Registry
71+
if: github.event_name != 'pull_request'
72+
uses: docker/login-action@v3
73+
with:
74+
registry: ${{ env.REGISTRY }}
75+
username: ${{ github.actor }}
76+
password: ${{ secrets.GITHUB_TOKEN }}
77+
78+
- name: Extract metadata for Frontend
79+
id: meta
80+
uses: docker/metadata-action@v5
81+
with:
82+
images: ${{ env.FRONTEND_IMAGE }}
83+
tags: |
84+
type=ref,event=branch
85+
type=sha,prefix=
86+
type=raw,value=latest,enable={{is_default_branch}}
87+
88+
- name: Build and push Frontend image
89+
uses: docker/build-push-action@v5
90+
with:
91+
context: ./frontend
92+
push: ${{ github.event_name != 'pull_request' }}
93+
tags: ${{ steps.meta.outputs.tags }}
94+
labels: ${{ steps.meta.outputs.labels }}
95+
cache-from: type=gha
96+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)