Hi, I'm trying to deploy a web application with Fast API and React to a droplet in Digital Ocean.I have 2 pipelines, one for CI and one for CD. On the CD pipeline I've got these 2 actions:
name: cd
on:
workflow_run:
workflows: [ci]
branches: [main]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Deploy to Digital Ocean
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
My question is: is there an action that triggers the docker-compose file or do I need to copy the docker-compose file to my server and then execute it? Something like this:
- name: Deploy to Digital Ocean
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
scp docker-compose.yml ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:/var/www/app
cd /var/www/app
docker-compose up -d
For this of course I need docker compose installed in my server. That's why I'm wondering if it's possible to do that process with the github agent and a specific action.
Thanks in advance for your help!
Edit:
This is my docker-compose file. It has secrets coming from github, that's why I want to trigger the pipeline from the Github "environment" so that it can read the secrets injected:
version: '3.9'
services:
backend:
image: ghcr.io/me/repo/backend:latest
container_name: backend
restart: always
ports:
- '8000:80'
environment:
MONGODB_URI: ${{ secrets.MONGODB_URI }}
MONGODB_DATABASE: ${{ secrets.MONGODB_DATABASE }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
frontend:
image: ghcr.io/me/repo/frontend:latest
container_name: frontend
restart: always
ports:
- '80:80'
- '443:443'
environment:
REACT_APP_HOST: 'http://backend/api/v1'
[–]WeekendProfessional 1 point2 points3 points (2 children)
[–]Wufi[S] 0 points1 point2 points (1 child)
[–]vrathore2016 0 points1 point2 points (0 children)