-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(github): created deploy action file
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Deploy Voodle Frontend to DigitalOcean | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install SSH Key | ||
uses: shimataro/ssh-key-action@v2 | ||
with: | ||
key: ${{ secrets.SERVER_SSH_KEY }} | ||
known_hosts: ${{ secrets.KNOWN_HOSTS }} | ||
|
||
- name: Deploy Frontend to DigitalOcean | ||
env: | ||
HOST: ${{ secrets.HOST }} | ||
USER: ${{ secrets.USER }} | ||
FRONTEND_ENV: ${{ secrets.FRONTEND_ENV }} | ||
run: | | ||
ssh $USER@$HOST << EOF | ||
# Navigate to the frontend project directory | ||
cd /var/www/voodle/client | ||
# Pull the latest changes | ||
git pull origin main | ||
# Update pnpm | ||
npm install -g pnpm | ||
# Setup environment | ||
echo "$FRONTEND_ENV" > .env | ||
# Install dependencies and build | ||
pnpm install | ||
pnpm run build | ||
# Restart the frontend service | ||
pm2 restart voodle-frontend || pm2 start "pnpm start" --name "voodle-frontend" | ||
# Save PM2 process list | ||
pm2 save | ||
# Reload Nginx if necessary | ||
sudo systemctl reload nginx | ||
EOF |