diff --git a/.github/workflows/ec2-deploy.yml b/.github/workflows/ec2-deploy.yml new file mode 100644 index 0000000..6687742 --- /dev/null +++ b/.github/workflows/ec2-deploy.yml @@ -0,0 +1,31 @@ +name: Deploy-to-EC2 + +on: + push: + branches: + - main + paths: + - "./src" + - ".github/workflows/ec2-deploy.yml" +jobs: + deploy: + name: Deploy to EC2 + runs-on: ubuntu-latest + + steps: + - name: Checkout the files + uses: actions/checkout@v2 + + - name: Deploy to server + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY }} + REMOTE_HOST: ${{ secrets.HOST_DNS }} + REMOTE_USER: ${{ secrets.USERNAME }} + TARGET: ${{ secrets.TARGET_DIR }} + ARGS: --delete + EXCLUDE: prod.env + SCRIPT_AFTER: | + cd ${{ secrets.TARGET_DIR }} + docker-compose up -d --build + docker system prune -af