docs: README에 로그 슬랙 알림 사진 추가 #60
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Backend | |
on: | |
push: | |
branches: | |
- develop | |
paths: | |
- 'backend/src/**' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to NCP Container Registry | |
run: | | |
set +x | |
echo "${{ secrets.NCP_SECRET_KEY }}" | docker login -u "${{ secrets.NCP_ACCESS_KEY }}" https://${{ secrets.NCP_REGISTRY_URL }} --password-stdin | |
- name: Build Docker Image | |
run: | | |
cd ${{ github.workspace }}/backend | |
echo "${{ secrets.DOT_ENV_PROD }}" >> .env.prod | |
docker build -t ${{ secrets.NCP_REGISTRY_URL }}/${{ secrets.DOCKER_IMAGE_NAME }} . | |
- name: Push Docker Image to NCP Container Registry | |
run: | | |
docker push ${{ secrets.NCP_REGISTRY_URL }}/${{ secrets.DOCKER_IMAGE_NAME }} | |
- name: Log out from Docker Registry | |
run: docker logout https://${{ secrets.NCP_REGISTRY_URL }} | |
- name: SSH and deploy backend | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa ${{ secrets.NCP_SERVER_USER }}@${{ secrets.NCP_SERVER_HOST }} \ | |
"export NCP_ACCESS_KEY=${{ secrets.NCP_ACCESS_KEY }} \ | |
NCP_SECRET_KEY=${{ secrets.NCP_SECRET_KEY }} \ | |
NCP_REGISTRY_URL=${{ secrets.NCP_REGISTRY_URL }} \ | |
DOCKER_IMAGE_NAME=${{ secrets.DOCKER_IMAGE_NAME }} && \ | |
/home/${{ secrets.NCP_SERVER_USER }}/deploy-backend.sh" |