Skip to content

Commit

Permalink
Update GitHub workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jloh02 committed Feb 20, 2024
1 parent b1815b2 commit daac292
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy from Master

on:
push:
branches: ["master"]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Deploy to Digital Ocean droplet via SSH action
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
command_timeout: 60m
script: |
ls
cd /home/treeckle/Treeckle-3.0
# Temp store changes
git stash
# Pull from git repo
git checkout master || true # Force return true so exit code is not 1
git pull
# Build
cd frontend
echo "${{ secrets.SUDO_PASSWORD }}" | sudo -S bash ./build-prod.sh
cd ..
echo "${{ secrets.SUDO_PASSWORD }}" | sudo docker-compose -f ./docker-compose.prod.yml up -d
# Restore changes
git stash pop
11 changes: 6 additions & 5 deletions .github/workflows/frontend-beta.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: Frontend Beta CI/CD
name: Deploy to Beta Site

on:
push:
pull_request:
branches: ["master"]
types: ["opened"]
paths:
- frontend/**
workflow_dispatch:

jobs:
build:
deploy-frontend:
runs-on: ubuntu-latest
steps:
- name: Deploy to Digital Ocean droplet via SSH action
Expand All @@ -27,14 +28,14 @@ jobs:
git stash
# Pull from git repo
git checkout master || true # Force return true so exit code is not 1
git checkout ${{ github.event.pull_request.head.sha || 'master' }} || true # Force return true so exit code is not 1
git pull
# Build
cd frontend
echo "${{ secrets.SUDO_PASSWORD }}" | sudo -S bash ./build.sh
cd ..
echo "${{ secrets.SUDO_PASSWORD }}" | sudo docker-compose -f ./docker-compose.prod.yml up -d
echo "${{ secrets.SUDO_PASSWORD }}" | sudo docker-compose -f ./docker-compose.prod.yml up -d frontend
# Restore changes
git stash pop || true # Force return true in case no changes stashed

0 comments on commit daac292

Please sign in to comment.