feat: cicd 수정 #1
Workflow file for this run
This file contains hidden or 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: Build and Deploy | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| - dev-be | |
| - feature-be-#51 | |
| jobs: | |
| build_and_deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Docker Hub login | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Build and Push Docker images | |
| run: | | |
| docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server -f ./dockerfile-server . | |
| docker push ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server | |
| - name: make deploy environment | |
| run: | | |
| echo "${{secrets.DEPLOY_ENV}}" > .env | |
| - name: Send files & deploy script | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| password: ${{ secrets.SSH_PASSWORD }} | |
| port: ${{ secrets.SSH_PORT }} | |
| source: ${{ secrets.BE_DEPLOY_FILES }} | |
| target: /corinee | |
| overwrite: true | |
| - name: Docker Container run | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| password: ${{ secrets.SSH_PASSWORD }} | |
| port: ${{ secrets.SSH_PORT }} | |
| script: | | |
| docker image rm -f ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server || true | |
| docker pull ${{ secrets.DOCKERHUB_USERNAME }}/corinee-server | |
| cd /corinee | |
| docker-compose -f docker-compose.server.yml down --rmi all | |
| docker-compose -f docker-compose.server.yml up -d | |
| rm -rf .env docker-compose.server.yml | |
| - name: Generate Error Report | |
| if: failure() | |
| run: | | |
| echo "Deployment Report" > report.txt | |
| echo "===================" >> report.txt | |
| echo "Commit SHA: ${{ github.sha }}" >> report.txt | |
| echo "Branch: ${{ github.ref }}" >> report.txt | |
| echo "Deployment Status: Failed" >> report.txt | |
| echo "Error Details: ${{ job.status }}" >> report.txt | |
| echo "===================" >> report.txt | |
| cat report.txt | |
| - name: Upload Error Report | |
| if: failure() | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: deployment-error-report | |
| path: report.txt |