fix: ec2 docker compose copy step #2
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: Deploy | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| deploy: | |
| name: Deploy to AWS EC2 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set repo lowercase | |
| run: echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV | |
| - name: Copy docker compose files to EC2 | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }}ZZ | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SERVER_SSH_KEY }} | |
| source: "docker/production/docker-compose.yml" | |
| target: "~/app" | |
| - name: Deploy on EC2 | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| # username: ${{ secrets.SERVER_USER }} | |
| username: ubuntu | |
| key: ${{ secrets.SERVER_SSH_KEY }} | |
| script: | | |
| cd ~/app/docker/production | |
| echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| docker pull ghcr.io/${{ env.REPO_LC }}/user-service:latest | |
| docker compose down | |
| docker compose up -d | |
| sleep 10 | |
| docker compose ps | |
| docker image prune -f | |
| # - name: Send Discord notification - Success | |
| # if: success() | |
| # uses: Ilshidur/action-discord@master | |
| # env: | |
| # DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| # with: | |
| # args: | | |
| # **배포 성공** | |
| # **Repository:** ${{ env.REPO_LC }} | |
| # **Tag:** ${{ github.ref_name }} | |
| # **Server:** ${{ secrets.SERVER_HOST }} | |
| # **Status:** Success! | |
| # | |
| # - name: Send Discord notification - Failure | |
| # if: failure() | |
| # uses: Ilshidur/action-discord@master | |
| # env: | |
| # DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| # with: | |
| # args: | | |
| # **배포 실패** | |
| # **Repository:** ${{ env.REPO_LC }} | |
| # **Tag:** ${{ github.ref_name }} | |
| # **Error:** 배포 중 오류가 발생했습니다. | |
| # **Check:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |