2024-04-28 17:34:42 +01:00
|
|
|
name: Deploy To Stage
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- develop
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
environment: stage
|
|
|
|
|
2024-04-28 17:36:36 +01:00
|
|
|
runs-on: node
|
2024-04-28 17:34:42 +01:00
|
|
|
|
|
|
|
steps:
|
2024-04-29 17:59:25 +01:00
|
|
|
- uses: actions/checkout@v4
|
2024-04-28 17:34:42 +01:00
|
|
|
- name: Use Node.js
|
2024-04-29 18:02:56 +01:00
|
|
|
uses: actions/setup-node@v4
|
2024-04-28 17:34:42 +01:00
|
|
|
with:
|
|
|
|
node-version: 18.x
|
|
|
|
- run: npm ci
|
|
|
|
- run: npm run build
|
|
|
|
- run: npm test
|
|
|
|
|
|
|
|
- name: "Copy files over to location"
|
|
|
|
run: cp -r . ${{ secrets.STAGE_REPO_PATH }}
|
|
|
|
|
|
|
|
deploy:
|
|
|
|
environment: prod
|
|
|
|
needs: build
|
2024-04-28 17:36:36 +01:00
|
|
|
runs-on: node
|
2024-04-28 17:34:42 +01:00
|
|
|
steps:
|
|
|
|
- uses: https://github.com/appleboy/ssh-action@v1.0.0
|
|
|
|
env:
|
|
|
|
DB_NAME: ${{ secrets.STAGE_DB_NAME }}
|
|
|
|
DB_AUTH_USER: ${{ secrets.STAGE_DB_AUTH_USER }}
|
|
|
|
DB_AUTH_PASS: ${{ secrets.STAGE_DB_AUTH_PASS }}
|
|
|
|
DB_HOST: ${{ secrets.STAGE_DB_HOST }}
|
|
|
|
DB_PORT: ${{ secrets.STAGE_DB_PORT }}
|
|
|
|
DB_ROOT_HOST: ${{ secrets.STAGE_DB_ROOT_HOST }}
|
|
|
|
DB_SYNC: ${{ secrets.STAGE_DB_SYNC }}
|
|
|
|
DB_LOGGING: ${{ secrets.STAGE_DB_LOGGING }}
|
|
|
|
DB_DATA_LOCATION: ${{ secrets.STAGE_DB_DATA_LOCATION }}
|
|
|
|
SERVER_PATH: ${{ secrets.STAGE_SSH_SERVER_PATH }}
|
|
|
|
BOT_TOKEN: ${{ secrets.STAGE_BOT_TOKEN }}
|
|
|
|
BOT_VER: ${{ vars.STAGE_BOT_VER }}
|
|
|
|
BOT_AUTHOR: ${{ vars.STAGE_BOT_AUTHOR }}
|
|
|
|
BOT_OWNERID: ${{ vars.STAGE_BOT_OWNERID }}
|
|
|
|
BOT_CLIENTID: ${{ vars.STAGE_BOT_CLIENTID }}
|
|
|
|
BOT_ENV: ${{ vars.STAGE_BOT_ENV }}
|
|
|
|
BOT_ADMINS: ${{ vars.STAGE_BOT_ADMINS }}
|
|
|
|
ABOUT_FUNDING: ${{ vars.STAGE_ABOUT_FUNDING }}
|
|
|
|
ABOUT_REPO: ${{ vars.STAGE_ABOUT_REPO }}
|
|
|
|
DATA_DIR: ${{ secrets.STAGE_DATA_DIR }}
|
|
|
|
GDRIVESYNC_AUTO: ${{ vars.STAGE_GDRIVESYNC_AUTO }}
|
|
|
|
EXPRESS_PORT: ${{ secrets.STAGE_EXPRESS_PORT }}
|
2024-05-03 18:37:08 +01:00
|
|
|
BOT_LOGLEVEL: ${{ vars.STAGE_BOT_LOGLEVEL }}
|
2024-04-28 17:34:42 +01:00
|
|
|
with:
|
|
|
|
host: ${{ secrets.STAGE_SSH_HOST }}
|
|
|
|
username: ${{ secrets.STAGE_SSH_USER }}
|
|
|
|
key: ${{ secrets.STAGE_SSH_KEY }}
|
|
|
|
port: ${{ secrets.STAGE_SSH_PORT }}
|
2024-05-03 18:37:08 +01:00
|
|
|
envs: DB_NAME,DB_AUTH_USER,DB_AUTH_PASS,DB_HOST,DB_PORT,DB_ROOT_HOST,DB_SYNC,DB_LOGGING,DB_DATA_LOCATION,BOT_TOKEN,BOT_VER,BOT_AUTHOR,BOT_OWNERID,BOT_CLIENTID,ABOUT_FUNDING,ABOUT_REPO,BOT_ENV,BOT_ADMINS,DATA_DIR,GDRIVESYNC_AUTO,SERVER_PATH,EXPRESS_PORT,BOT_LOGLEVEL
|
2024-04-28 17:34:42 +01:00
|
|
|
script: |
|
2024-04-28 17:40:00 +01:00
|
|
|
source .sshrc \
|
|
|
|
&& cd /home/vylpes/apps/card-drop/card-drop_stage \
|
2024-04-28 17:34:42 +01:00
|
|
|
&& docker compose down \
|
|
|
|
&& (pm2 stop card-drop_stage || true) \
|
|
|
|
&& (pm2 delete card-drop_stage || true) \
|
|
|
|
&& docker compose up -d \
|
|
|
|
&& sleep 10 \
|
|
|
|
&& yarn run db:up \
|
|
|
|
&& pm2 start --name card-drop_stage dist/bot.js
|