diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 180d384..d8ff7ef 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,30 +30,30 @@ jobs: tags: ${{ secrets.DOCKER_USERNAME }}/backend-web:latest - # deploy: - # needs: build-and-share - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v3 - - # - name: Configure AWS credentials - # uses: aws-actions/configure-aws-credentials@v1 - # with: - # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - # aws-region: eu-north-1 - - # - name: Deploy to EC2 - # env: - # PRIVATE_KEY: ${{ secrets.EC2_SSH_PRIVATE_KEY }} - # HOST: ${{ secrets.EC2_HOST }} - # USER: ${{ secrets.EC2_USER }} - # run: | - # echo "$PRIVATE_KEY" > private_key && chmod 600 private_key - # ssh -o StrictHostKeyChecking=no -i private_key ${USER}@${HOST} ' - # sudo docker compose pull && - # sudo docker compose up -d && - # sudo docker image prune -f && - # sudo systemctl restart nginx - # ' + deploy: + needs: build-and-share + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-north-1 + + - name: Deploy to EC2 + env: + PRIVATE_KEY: ${{ secrets.EC2_SSH_PRIVATE_KEY }} + HOST: ${{ secrets.EC2_HOST }} + USER: ${{ secrets.EC2_USER }} + run: | + echo "$PRIVATE_KEY" > private_key && chmod 600 private_key + ssh -o StrictHostKeyChecking=no -i private_key ${USER}@${HOST} ' + sudo docker compose pull && + sudo docker compose up -d && + sudo docker image prune -f && + sudo systemctl restart nginx + '