Skip to content

Commit c6e2e31

Browse files
committed
cicd test
1 parent 74fbb11 commit c6e2e31

3 files changed

Lines changed: 103 additions & 2 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: APIGateway CI - Build, Push, and Trigger CD
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
build-push-trigger:
9+
name: Build, Push APIGateway Image, and Trigger Jenkins CD
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Log in to Docker Hub
17+
uses: docker/login-action@v3
18+
with:
19+
username: ${{ secrets.DOCKERHUB_USERNAME }}
20+
password: ${{ secrets.DOCKERHUB_TOKEN }}
21+
22+
- name: Extract metadata (tags, labels) for Docker
23+
id: meta
24+
uses: docker/metadata-action@v5
25+
with:
26+
images: msj9965/alog-apigateway # APIGateway 이미지 이름
27+
tags: | # 태그 전략: main, latest, sha-short
28+
type=raw,value=main,enable={{is_default_branch}}
29+
type=raw,value=latest,enable={{is_default_branch}}
30+
type=sha,prefix=sha-,format=short
31+
32+
- name: Build and push Docker image
33+
uses: docker/build-push-action@v5
34+
with:
35+
context: .
36+
file: ./Dockerfile # APIGateway 레포지토리의 Dockerfile
37+
push: true
38+
tags: ${{ steps.meta.outputs.tags }}
39+
labels: ${{ steps.meta.outputs.labels }}
40+
41+
- name: Trigger Jenkins CD Pipeline for APIGateway
42+
if: success()
43+
env:
44+
JENKINS_URL: ${{ secrets.JENKINS_URL }}
45+
JENKINS_JOB_NAME: ${{ secrets.JENKINS_JOB_NAME_GATEWAY }} # APIGateway용 Jenkins 작업 이름 Secret
46+
JENKINS_TRIGGER_TOKEN: ${{ secrets.JENKINS_TRIGGER_TOKEN_GATEWAY }} # APIGateway용 Jenkins 트리거 토큰 Secret
47+
JENKINS_USER_ID: ${{ secrets.JENKINS_USER_ID }}
48+
JENKINS_USER_API_TOKEN: ${{ secrets.JENKINS_USER_API_TOKEN }}
49+
# Jenkins에 전달할 이미지 태그 (여기서는 'main' 태그를 사용)
50+
IMAGE_TO_DEPLOY_TAG: main
51+
run: |
52+
echo "Triggering Jenkins job: '${JENKINS_JOB_NAME}' for APIGateway with image tag: '${IMAGE_TO_DEPLOY_TAG}'"
53+
curl -X POST -u "${JENKINS_USER_ID}:${JENKINS_USER_API_TOKEN}" \
54+
"${JENKINS_URL}/job/${JENKINS_JOB_NAME}/buildWithParameters?token=${JENKINS_TRIGGER_TOKEN}&IMAGE_TAG=${IMAGE_TO_DEPLOY_TAG}"

apigateway-deployment.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: apigateway-service
5+
namespace: gateway
6+
labels:
7+
app: apigateway-service
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: apigateway-service
13+
template:
14+
metadata:
15+
labels:
16+
app: apigateway-service
17+
spec:
18+
containers:
19+
- name: apigateway-service
20+
image: msj9965/alog-apigateway:main
21+
ports:
22+
- containerPort: 8000
23+
env:
24+
- name: JWT_SECRET
25+
valueFrom:
26+
secretKeyRef:
27+
name: apigateway-secret
28+
key: JWT_SECRET
29+
readinessProbe:
30+
httpGet:
31+
path: /health-check
32+
port: 8000
33+
initialDelaySeconds: 10
34+
periodSeconds: 10
35+
livenessProbe:
36+
httpGet:
37+
path: /health-check
38+
port: 8000
39+
initialDelaySeconds: 30
40+
periodSeconds: 20
41+
resources:
42+
requests:
43+
cpu: "100m"
44+
memory: "256Mi"
45+
limits:
46+
cpu: "200m"
47+
memory: "512Mi"

src/main/java/com/gucci/apigatewayservice/filter/JwtAuthorizationFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
7979
"/swagger/blog-service/swagger-ui/index.html",
8080
"/swagger/blog-service/v3/api-docs",
8181
"/api/github-service/health-check",
82-
"/api/user-service/profile-nickname/**",
83-
"/api/user-service/details/**"
82+
"/api/user-service/details",
83+
"/api/user-service/profile-nickname"
8484

8585

8686
);

0 commit comments

Comments
 (0)