Skip to content

Commit

Permalink
Merge pull request #240 from prgrms-web-devcourse-final-project/feature/
Browse files Browse the repository at this point in the history
#234-AI-prompt-추가

[feat] main branch CI/CD 수정
  • Loading branch information
Dom1046 authored Dec 26, 2024
2 parents 3e5ae95 + dc7b496 commit cef2434
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:


# 생성된 파일들을 아티팩트로 업로드
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: application.properties
path: ./src/main/resources/application.properties
Expand All @@ -50,6 +50,39 @@ jobs:
artifact=$(ls ./build/libs/*.jar | head -n 1)
echo "artifact=$artifact" >> $GITHUB_ENV
# 9. SSH 키 설정
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.EC2_SSH_KEY }}
# GitHub Secrets에 저장된 EC2 SSH 개인 키를 SSH 에이전트에 로드

# 10. GCP Credentials 디코딩 및 EC2로 전송
- name: Decode GCP Credentials
run: echo "${{ secrets.GCP_CREDENTIALS }}" | base64 --decode > gcp-key.json
# GitHub Secrets에 저장된 Base64 인코딩된 GCP JSON Key를 디코딩하여 로컬에 저장

- name: Copy GCP Credentials to EC2
run: scp -o StrictHostKeyChecking=no gcp-key.json ${{ secrets.EC2_USER }}@${{ secrets.EC2_IP }}:/home/${{ secrets.EC2_USER }}/gcp-key.json
# 디코딩된 GCP JSON Key 파일을 EC2 서버로 전송
# YOUR_EC2_IP -> GitHub Secrets에 저장된 EC2 IP 주소 (${ secrets.EC2_IP })
# ec2-user -> GitHub Secrets에 저장된 EC2 SSH 사용자 이름 (${ secrets.EC2_USER })

# 11. EC2에서 GCP Credentials 설정
- name: Set up GCP Credentials on EC2
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_IP }} << 'EOF'
mkdir -p ~/.gcp
mv /home/${{ secrets.EC2_USER }}/gcp-key.json ~/.gcp/key.json
chmod 600 ~/.gcp/key.json
export GOOGLE_APPLICATION_CREDENTIALS=~/.gcp/key.json
# 환경 변수 설정을 영구적으로 추가
echo 'export GOOGLE_APPLICATION_CREDENTIALS=~/.gcp/key.json' >> ~/.bash_profile
EOF
# EC2 서버에서 GCP Credentials 설정
# YOUR_EC2_IP -> GitHub Secrets에 저장된 EC2 IP 주소 (${ secrets.EC2_IP })
# ec2-user -> GitHub Secrets에 저장된 EC2 SSH 사용자 이름 (${ secrets.EC2_USER })

# 빈스토크 배포
- name: Deploy to Elastic Beanstalk
uses: einaregilsson/beanstalk-deploy@v20
Expand Down

0 comments on commit cef2434

Please sign in to comment.