-
Notifications
You must be signed in to change notification settings - Fork 1
Deploy/79 GitHub Secrets를 이용한 환경 변수 관리 설정 #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -104,6 +104,16 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # 프로젝트 디렉토리로 이동 | ||||||||||||||||||||||||||||||||||||||||||||
| cd ~/projects/GlobalNomad | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # .env 파일 생성 | ||||||||||||||||||||||||||||||||||||||||||||
| echo "📝 Creating .env file from secrets..." | ||||||||||||||||||||||||||||||||||||||||||||
| # 기존 .env 파일이 있다면 삭제하여 최신 상태 유지 | ||||||||||||||||||||||||||||||||||||||||||||
| rm -f .env | ||||||||||||||||||||||||||||||||||||||||||||
| touch .env | ||||||||||||||||||||||||||||||||||||||||||||
| echo "NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}" >> .env | ||||||||||||||||||||||||||||||||||||||||||||
| echo "NEXT_PUBLIC_TEAM_ID=${{ secrets.NEXT_PUBLIC_TEAM_ID }}" >> .env | ||||||||||||||||||||||||||||||||||||||||||||
| echo "NEXT_PUBLIC_KAKAO_APP_JS_KEY=${{ secrets.NEXT_PUBLIC_KAKAO_APP_JS_KEY }}" >> .env | ||||||||||||||||||||||||||||||||||||||||||||
| echo "NEXT_PUBLIC_API_SERVER_URL=${{ secrets.NEXT_PUBLIC_API_SERVER_URL }}" >> .env | ||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 환경 변수 값이 로그에 노출될 위험이 있습니다
- rm -f .env
- touch .env
- echo "NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}" >> .env
- echo "NEXT_PUBLIC_TEAM_ID=${{ secrets.NEXT_PUBLIC_TEAM_ID }}" >> .env
- echo "NEXT_PUBLIC_KAKAO_APP_JS_KEY=${{ secrets.NEXT_PUBLIC_KAKAO_APP_JS_KEY }}" >> .env
- echo "NEXT_PUBLIC_API_SERVER_URL=${{ secrets.NEXT_PUBLIC_API_SERVER_URL }}" >> .env
+ rm -f .env
+ # 값이 로그에 찍히지 않도록 cat-heredoc 사용
+ cat > .env <<EOF
+NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}
+NEXT_PUBLIC_TEAM_ID=${{ secrets.NEXT_PUBLIC_TEAM_ID }}
+NEXT_PUBLIC_KAKAO_APP_JS_KEY=${{ secrets.NEXT_PUBLIC_KAKAO_APP_JS_KEY }}
+NEXT_PUBLIC_API_SERVER_URL=${{ secrets.NEXT_PUBLIC_API_SERVER_URL }}
+EOF📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 로그에 노출되는 부분의 문제에 관해서 궁금한게 하나 있는데 GitHub Actions에서 이 문제를 해결하기 위해서 자동으로 Secrets를 마스킹이였나? 하는 기능이 내장되어 있는거 아닌가? 찾아보니 워크플로우 로그에 Secrets 값이 출력 되려고 하면 깃허브에서 이 값을 다른값이였었나 별표였었나 아무튼 다른값으로 대체해주는 걸로 알고 있는데 잘못 알고있는건가 궁금해서 말이야. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LeeCh0129 맞습니다! GitHub Actions에는 자동 시크릿 마스킹 기능이 내장되어 있어서, 워크플로우 로그에 등록된 secrets 값이 출력되려고 하면 하지만 몇 가지 마스킹이 실패할 수 있는 경우들이 있어서 제가 heredoc 방식을 제안했습니다: 마스킹이 동작하는 경우- name: Test
run: echo "${{ secrets.MY_SECRET }}" # *** 로 마스킹됨마스킹이 실패할 수 있는 경우들
ssh user@host << 'ENDSSH'
echo "API_URL=${{ secrets.API_URL }}" # SSH 세션 내부에서는 마스킹이 불완전할 수 있음
ENDSSH
echo "${{ secrets.API_URL }}" | base64 # 인코딩된 값은 마스킹되지 않음
echo "Config: prefix-${{ secrets.API_URL }}-suffix" # 변형된 형태는 감지 못할 수 있음현재 코드에서는 SSH 세션 내부에서 echo를 실행하고 있어서, GitHub의 마스킹이 완벽하게 동작하지 않을 가능성이 있습니다. 그래도 일반적인 경우에는 GitHub의 자동 마스킹이 잘 동작하니, 현재 코드를 그대로 유지하셔도 큰 문제는 없을 것 같습니다! |
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # 최신 코드 가져오기 | ||||||||||||||||||||||||||||||||||||||||||||
| echo "🔄 Pulling latest code..." | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,10 @@ services: | |
| context: . | ||
| dockerfile: Dockerfile | ||
| restart: unless-stopped | ||
|
|
||
| env_file: | ||
| - .env | ||
|
|
||
|
Comment on lines
+15
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chain
별도 변경은 없어도 되지만 배포 전 두 항목을 검증해 주세요. 아래 스크립트를 실행해 위 결과를 바탕으로 🏁 Script executed: #!/bin/bash
# 1) .gitignore에 .env가 등록되어 있는지 확인
echo "🔍 .gitignore에서 '.env' 무시 설정 확인"
rg -n '^\s*\.env(\s*#.*)?$' .gitignore || echo "⚠️ .gitignore에 '.env'가 없습니다."
# 2) 저장소 루트에 .env 파일이 커밋된 상태인지 확인
echo "🔍 저장소 루트에 '.env' 파일 존재 여부 확인"
if ls -A | grep -q '^\.env$'; then
echo "⚠️ 저장소에 '.env' 파일이 존재합니다. 커밋되지 않도록 .gitignore에 추가해주세요."
else
echo "✅ '.env' 파일이 커밋되지 않았습니다."
fiLength of output: 360 .env 무시 설정 추가 및 로드 테스트 필요
🤖 Prompt for AI Agents |
||
| environment: | ||
| - NODE_ENV=production | ||
| networks: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
.env파일 권한을 제한하여 서버 내 노출을 방지하세요파일을 만들기만 하고 권한을 조정하지 않아 기본 umask 값에 따라 다른 사용자도 읽을 수 있습니다.
touch .env +chmod 600 .env # 소유자만 읽기/쓰기📝 Committable suggestion
🤖 Prompt for AI Agents