This repository has been archived by the owner on Jul 14, 2024. It is now read-only.
Update deploy.yml #8
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
name: Deploy App | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
jobs: | |
auto-deploy: | |
runs-on: self-hosted | |
env: | |
PORT: ${{ secrets.PORT }} | |
CLIENT_ID: "${{ secrets.CLIENT_ID }}" | |
CLIENT_SECRET: "${{ secrets.CLIENT_SECRET }}" | |
GRAPHQL_ENDPOINT: "${{ secrets.GRAPHQL_ENDPOINT }}" | |
NEXTAUTH_SECRET: "${{ secrets.NEXTAUTH_SECRET }}" | |
NEXTAUTH_URL: "${{ secrets.NEXTAUTH_URL }}" | |
PROXY_URI: "${{ secrets.PROXY_URI }}" | |
API_URI: "${{ secrets.API_URI }}" | |
API_KEY: "${{ secrets.API_KEY }}" | |
DISQUS_SHORTNAME: "${{ secrets.DISQUS_SHORTNAME }}" | |
ADMIN_USERNAME: "${{ secrets.ADMIN_USERNAME }}" | |
DATABASE_URL: "${{ secrets.DATABASE_URL }}" | |
REDIS_URL: "${{ secrets.REDIS_URL }}" | |
environment: production | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
- name: Install dependencies | |
run: bun install | |
- name: Generate Prisma | |
run: bunx prisma generate || exit | |
- name: Build the project | |
run: BUILD_DIR=temp bun run build || exit | |
- name: Check if temp directory exists | |
run: | | |
if [ ! -d "temp" ]; then | |
echo "temp Directory does not exist!" | |
exit 1 | |
else | |
echo "temp Directory exists." | |
fi | |
- name: Remove .next directory | |
run: rm -rf .next | |
- name: Move temp to .next directory | |
run: mv temp .next | |
- name: Set HOME environment variable | |
run: echo 'export HOME=$HOME' >> $GITHUB_ENV | |
- name: Set PORT | |
run: echo "PORT=1000" >> $GITHUB_ENV | |
- name: Check if PM2 process exists | |
run: | | |
if pm2 list | grep -q 'moopa'; then | |
echo "PM2 process 'moopa' exists" | |
else | |
echo "PM2 process 'moopa' does not exist, starting a new process" | |
pm2 start bun -n moopa -- start | |
fi | |
- name: Reload PM2 | |
run: | | |
pm2 stop moopa | |
pm2 start moopa --update-env | |
pm2 save | |
nginx -s reload |