Skip to content

Commit a8e906e

Browse files
authored
Merge pull request #349 from Pseudo-Lab/feat/k8s-ci-setup
feat(ci): introduce k8s workflows for homepage
2 parents 65d9049 + 7599b85 commit a8e906e

2 files changed

Lines changed: 93 additions & 6 deletions

File tree

.github/workflows/devfactory-homepage.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ name: 🚀 DevFactory Homepage Deploy
22
run-name: 🚀 Deploying to Production by @${{ github.actor }}
33

44
on:
5-
push:
6-
branches:
7-
- main
8-
paths:
9-
- 'platform/**'
10-
- '.github/workflows/devfactory-homepage.yml'
5+
# push:
6+
# branches:
7+
# - main
8+
# paths:
9+
# - 'platform/**'
10+
# - '.github/workflows/devfactory-homepage.yml'
1111
workflow_dispatch:
1212

1313
# 같은 브랜치 동시 실행 시 이전 잡 취소(경쟁 배포 방지)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: CI - Homepage (K8s)
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- 'platform/**'
8+
- '.github/workflows/k8s/ci-homepage.yml'
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME_PREFIX: pseudo-lab/devfactory
14+
15+
jobs:
16+
build-and-push:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
strategy:
22+
matrix:
23+
include:
24+
- component: homepage-frontend
25+
context: ./platform/frontend
26+
image: homepage-frontend
27+
- component: homepage-backend
28+
context: ./platform/server
29+
image: homepage-backend
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
- name: Log in to the Container registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Extract metadata (tags, labels) for Docker
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_PREFIX }}-${{ matrix.image }}
47+
tags: |
48+
type=sha,prefix=sha-,format=short
49+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
50+
51+
- name: Build and push Docker image
52+
uses: docker/build-push-action@v5
53+
with:
54+
context: ${{ matrix.context }}
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
59+
deploy-handoff:
60+
needs: build-and-push
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Checkout Ops Repository
64+
uses: actions/checkout@v4
65+
with:
66+
repository: Pseudo-Lab/DevFactory-Ops
67+
token: ${{ secrets.OPS_REPO_TOKEN }}
68+
path: ops-repo
69+
70+
- name: Setup Kustomize
71+
uses: imranismail/setup-kustomize@v2
72+
73+
- name: Update Image Tags in Ops Repo
74+
run: |
75+
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
76+
cd ops-repo/services/homepage/overlays/prod
77+
kustomize edit set image ghcr.io/pseudo-lab/devfactory-homepage-backend=ghcr.io/pseudo-lab/devfactory-homepage-backend:sha-$SHORT_SHA
78+
kustomize edit set image ghcr.io/pseudo-lab/devfactory-homepage-frontend=ghcr.io/pseudo-lab/devfactory-homepage-frontend:sha-$SHORT_SHA
79+
80+
- name: Commit and Push to Ops Repo
81+
run: |
82+
cd ops-repo
83+
git config user.name "github-actions[bot]"
84+
git config user.email "github-actions[bot]@users.noreply.github.com"
85+
git add .
86+
git commit -m "chore(deploy): update homepage images to sha-${{ github.sha }}" || echo "No changes to commit"
87+
git push

0 commit comments

Comments
 (0)