Deploy API Gateway to DigitalOcean (PRE) #9
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 API Gateway to DigitalOcean (PRE) | |
| on: | |
| workflow_dispatch: # Allows manual triggering | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Build Docker Image | |
| run: | | |
| docker compose -f ./docker/docker-compose.yml build | |
| - name: Save Docker Image | |
| run: | | |
| docker save api-gateway:latest | gzip > api-gateway.tar.gz | |
| - name: Copy Docker Image and Compose File to Droplet | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USER }} | |
| key: ${{ secrets.SSH_KEY }} | |
| source: "./api-gateway.tar.gz,./docker-compose.yml" | |
| target: /opt/api-gateway/ | |
| - name: Deploy with Docker Compose | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_KEY }} | |
| script: | | |
| cd /opt/api-gateway | |
| # Stop and remove old services | |
| docker-compose down || true | |
| # Load the new Docker image | |
| gunzip -c api-gateway.tar.gz | docker load | |
| # Start the service with the new image | |
| docker-compose up -d |