From c859c70e9b1482310563e5a645399a9d2e45c581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Vin=C3=ADcius=20Sena?= Date: Thu, 16 May 2024 20:34:52 -0300 Subject: [PATCH] add deploy.yml. Deploy to DigitalOcean --- .github/workflows/deploy.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f6d3da4 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,33 @@ +name: Deploy to DigitalOcean + +on: + push: + branches: + - setup/digital-ocean + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build Docker image + run: docker build -t abibliadigital:latest . + + - name: Set up SSH + uses: webfactory/ssh-agent@v0.5.3 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Copy Docker image to DigitalOcean + run: | + docker save abibliadigital:latest | bzip2 | ssh root@${{ secrets.DROPLET_IP }} 'bunzip2 | docker load' + + - name: Deploy to DigitalOcean + run: | + ssh root@${{ secrets.DROPLET_IP }} "docker-compose -f /path/to/docker-compose.yml up -d"