Skip to content

Transfer application code and docker-compose.yml to droplet #12

Transfer application code and docker-compose.yml to droplet

Transfer application code and docker-compose.yml to droplet #12

Workflow file for this run

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 images
run: docker-compose build
- name: List Docker images
run: docker images
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add DigitalOcean droplet to known_hosts
run: |
ssh-keyscan ${{ secrets.DROPLET_IP }} >> ~/.ssh/known_hosts
- name: Save and transfer API image to DigitalOcean
run: |
IMAGE_API_ID=$(docker images -q abibliadigital_api:latest)
docker save $IMAGE_API_ID | bzip2 | ssh root@${{ secrets.DROPLET_IP }} 'bzip2 -d | docker load'
- name: Save and transfer Mongo image to DigitalOcean
run: |
IMAGE_MONGO_ID=$(docker images -q abibliadigital_mongo:latest)
docker save $IMAGE_MONGO_ID | bzip2 | ssh root@${{ secrets.DROPLET_IP }} 'bzip2 -d | docker load'
- name: Transfer application code to DigitalOcean
run: |
rsync -avz --exclude 'node_modules' --exclude '.git' . root@${{ secrets.DROPLET_IP }}:/root/app
- name: Transfer docker-compose.yml to DigitalOcean
run: |
scp docker-compose.yml root@${{ secrets.DROPLET_IP }}:/root/docker-compose.yml
- name: Deploy to DigitalOcean
run: |
ssh root@${{ secrets.DROPLET_IP }} "cd /root/app && docker-compose -f /root/docker-compose.yml up -d"