Skip to content

Commit 9a034d5

Browse files
committed
work
1 parent 7dd7685 commit 9a034d5

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,6 @@ jobs:
9090
mkdir -p "${{ env.BACKEND_DIR }}"
9191
printf "%s" "${DOT_ENV}" > "${{ env.BACKEND_DIR }}/.env"
9292
93-
# GA4 서비스 계정 파일 생성
94-
- name: Create GA4 Service Account Key
95-
run: |
96-
mkdir -p src/main/resources
97-
echo "${{ secrets.GA4_JSON }}" > src/main/resources/ga4-service-account.json
98-
9993
- name: Docker Buildx 설치
10094
uses: docker/setup-buildx-action@v3
10195

@@ -151,6 +145,18 @@ jobs:
151145
[[ -n "${INSTANCE_ID}" && "${INSTANCE_ID}" != "None" ]] || { echo "No running instance found"; exit 1; }
152146
echo "INSTANCE_ID=${INSTANCE_ID}" >> "${GITHUB_ENV}"
153147
148+
# 3) GA4 JSON을 EC2에 복사
149+
- name: Copy GA4 JSON to EC2
150+
run: |
151+
echo "${{ secrets.GA4_JSON }}" > ga4-service-account.json
152+
aws ssm send-command \
153+
--document-name "AWS-RunShellScript" \
154+
--targets "Key=instanceIds,Values=${{ env.INSTANCE_ID }}" \
155+
--parameters 'commands=["mkdir -p /home/ec2-user/secrets", "echo \"$GA4_JSON\" > /home/ec2-user/secrets/ga4-service-account.json"]' \
156+
--region ${{ secrets.AWS_REGION }}
157+
env:
158+
GA4_JSON: ${{ secrets.GA4_JSON }}
159+
154160
# 원격(SSM)으로 Blue/Green 스위치 수행
155161
- name: AWS SSM Send-Command
156162
uses: peterkimzz/aws-ssm-send-command@master
@@ -243,6 +249,7 @@ jobs:
243249
--restart unless-stopped \
244250
--network "${NET}" \
245251
-e TZ=Asia/Seoul \
252+
-v /home/ec2-user/secrets/ga4-service-account.json:/app/secrets/ga4-service-account.json:ro \
246253
"${IMAGE}"
247254
248255
# ---------------------------------------------------------

src/main/resources/application-prod.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ spring:
1717
hibernate:
1818
dialect: org.hibernate.dialect.PostgreSQLDialect
1919
show-sql: true
20+
analytics:
21+
ga4:
22+
credentials-file: file:/app/ga4-service-account.json
2023

2124
logging:
2225
level:

0 commit comments

Comments
 (0)