Skip to content

created action for gauzy api stage on digitalOcean droplet #55

created action for gauzy api stage on digitalOcean droplet

created action for gauzy api stage on digitalOcean droplet #55

name: Deploy to DigitalOcean Droplet Demo
on:
push:
branches:
- test-do-droplet2
jobs:
deploy:
runs-on: buildjet-4vcpu-ubuntu-2204
environment: demo
steps:
- name: checkout out code
uses: actions/checkout@v4
- name: Globalise Ingress certificate type env
run: |
echo "INGRESS_CERT_TYPE=${{ env.INGRESS_CERT_TYPE }}" >> $GITHUB_ENV
env:
INGRESS_CERT_TYPE: 'letsencrypt'
- name: Generate TLS Secrets for DO Droplet
run: |
rm -f $GITHUB_WORKSPACE/.deploy/ssh/with-cloudflare/ingress.api.crt $GITHUB_WORKSPACE/.deploy/ssh/with-cloudflare/ingress.api.key
echo ${{ secrets.INGRESS_API_CERT }} | base64 --decode > $GITHUB_WORKSPACE/.deploy/ssh/with-cloudflare/ingress.api.crt
echo ${{ secrets.INGRESS_API_CERT_KEY }} | base64 --decode > $GITHUB_WORKSPACE/.deploy/ssh/with-cloudflare/ingress.api.key
- name: Copy file via scp
uses: appleboy/scp-action@master
with:
host: ${{secrets.DO_DROPLET_DEMO_HOST}}
username: ${{secrets.DO_DROPLET_USERNAME}}
key: ${{secrets.DO_DROPLET_KEY}}
source: '.deploy/ssh/with-cloudflare/docker-compose.api.demo.cloudflare.pre.yml,.deploy/ssh/with-letsencrypt/docker-compose.api.demo.letsencrypt.pre.yml,.deploy/ssh/with-cloudflare/nginx.demo.pre.cloudflare.conf,.deploy/ssh/with-letsencrypt/demo.conf.d,.deploy/ssh/with-cloudflare/ingress.api.crt,.deploy/ssh/with-cloudflare/ingress.api.key'
target: '.'
- name: Deploy to DigitalOcean Droplet
uses: appleboy/ssh-action@master
with:
host: ${{secrets.DO_DROPLET_DEMO_HOST}}
username: ${{secrets.DO_DROPLET_USERNAME}}
key: ${{secrets.DO_DROPLET_KEY}}
script: |
if [ "${{ env.INGRESS_CERT_TYPE }}" = "cloudflare" ]; then
docker-compose -f .deploy/ssh/with-letsencrypt/docker-compose.api.demo.letsencrypt.pre.yml down
docker-compose -f .deploy/ssh/with-cloudflare/docker-compose.api.demo.cloudflare.pre.yml up -d
elif [ "${{ env.INGRESS_CERT_TYPE }}" = "letsencrypt" ]; then
docker-compose -f .deploy/ssh/with-cloudflare/docker-compose.api.demo.cloudflare.pre.yml down
docker-compose -f .deploy/ssh/with-letsencrypt/docker-compose.api.demo.letsencrypt.pre.yml up -d
else
echo "Unknown INGRESS_CERT_TYPE: $INGRESS_CERT_TYPE"
exit 1
fi