Skip to content

Commit fd05fb0

Browse files
committed
ci: Add GHCR publish workflow for Docker images
1 parent 5995c5c commit fd05fb0

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Publish to GHCR
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags:
7+
- 'v*'
8+
workflow_dispatch:
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME_BACKEND: ${{ github.repository }}/backend
13+
IMAGE_NAME_FRONTEND: ${{ github.repository }}/frontend
14+
15+
jobs:
16+
build-and-push:
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: Log in to GitHub Container Registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract metadata for Backend
34+
id: meta-backend
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BACKEND }}
38+
tags: |
39+
type=ref,event=branch
40+
type=semver,pattern={{version}}
41+
type=semver,pattern={{major}}.{{minor}}
42+
type=sha
43+
44+
- name: Build and push Backend image
45+
uses: docker/build-push-action@v5
46+
with:
47+
context: ./AIGovHub/backend
48+
push: true
49+
tags: ${{ steps.meta-backend.outputs.tags }}
50+
labels: ${{ steps.meta-backend.outputs.labels }}
51+
52+
- name: Extract metadata for Frontend
53+
id: meta-frontend
54+
uses: docker/metadata-action@v5
55+
with:
56+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_FRONTEND }}
57+
tags: |
58+
type=ref,event=branch
59+
type=semver,pattern={{version}}
60+
type=semver,pattern={{major}}.{{minor}}
61+
type=sha
62+
63+
- name: Build and push Frontend image
64+
uses: docker/build-push-action@v5
65+
with:
66+
context: ./AIGovHub/frontend
67+
push: true
68+
tags: ${{ steps.meta-frontend.outputs.tags }}
69+
labels: ${{ steps.meta-frontend.outputs.labels }}

0 commit comments

Comments
 (0)