Skip to content

Commit

Permalink
add: FCM secret.json을 �CICD에서 숨겨서 배포하기
Browse files Browse the repository at this point in the history
  • Loading branch information
wellbeing-dough committed Jan 11, 2024
1 parent 2991f82 commit 6767bd4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
- Study Hub
- [Spring Batch](dongwoo/project/studyHub/Spring Batch 모집글 상태 자동 변환.md)
- [EC2 Timezone](dongwoo/project/studyHub/Github%20Actions,%20ec2%20timezone변경.md)
- [Deploy Timezone](dongwoo/project/studyHub/CI서버 Repository Test 에서 시간 정렬이 안되는 이슈.md)
- [Deploy Timezone](dongwoo/project/studyHub/CI서버 Repository Test 에서 시간 정렬이 안되는 이슈.md)
- [Deploy Secret.json](dongwoo/project/studyHub/FCM%20secret.json을%20%08CICD에서%20숨겨서%20배포하기.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## 문제점
1. FCM 시크릿키는 숨겨야 함
2. secret.json을 이그노어 함
3. 그럼 github actions의 CICD에서는 이그노어 된 파일을 볼 수 없음
4. yml의 환경변수가 아니라 json이라서 ELB 환경변수에 넣기도 힘듬

## 해결 방법
1. 깃헙 시크릿 키에 json파일을 저장
2. deploy.yml에서 빌드하기전에 src/main/resources/firebase 경로에 시크릿 키에서 가져온 json 넣는 스크립트 코드 작성

이렇게 하려 했는데 github actions에서 시크릿에 json 넣는것을 피하라 했다
```
To help ensure that GitHub redacts your secret in logs,
avoid using structured data as the values of secrets.
For example, avoid creating secrets that contain JSON or encoded Git blobs.
```
그래서 해결하다가 중간에 바꿨다
1. 깃헙 시크릿에 json파일을 base64로 인코딩 하여 저장
2. deploy.yml에서 빌드하기전에 시크릿에서 가져온 json base64로 디코딩
3. src/main/resources/firebase 에 디코딩한 json저장

```
- name: Setup Firebase service key
run: |
mkdir -p src/main/resources/firebase
echo ${{ secrets.FIREBASE_SERVICE_KEY_BASE64_ENCODE }} | base64 -d > src/main/resources/firebase/firebase-service-key.json
```

0 comments on commit 6767bd4

Please sign in to comment.