2024-04-28 15:49:54 +01:00
|
|
|
name: Deploy To Production
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
environment: prod
|
|
|
|
|
2024-04-28 16:02:46 +01:00
|
|
|
runs-on: node
|
2024-04-28 15:49:54 +01:00
|
|
|
|
|
|
|
steps:
|
2024-04-29 17:51:22 +01:00
|
|
|
- uses: actions/checkout@v4
|
2024-04-28 15:49:54 +01:00
|
|
|
- name: Use Node.js
|
2024-06-24 18:52:23 +01:00
|
|
|
uses: actions/setup-node@v4
|
2024-04-28 15:49:54 +01:00
|
|
|
with:
|
|
|
|
node-version: 18.x
|
2024-06-29 18:26:25 +01:00
|
|
|
- run: yarn install --frozen-lockfile
|
|
|
|
- run: yarn build
|
|
|
|
- run: yarn test
|
2024-04-28 15:49:54 +01:00
|
|
|
|
2024-04-28 17:01:11 +01:00
|
|
|
- name: "Copy files over to location"
|
|
|
|
run: cp -r . ${{ secrets.PROD_REPO_PATH }}
|
2024-04-28 15:49:54 +01:00
|
|
|
|
|
|
|
deploy:
|
|
|
|
environment: prod
|
|
|
|
needs: build
|
2024-04-28 16:02:46 +01:00
|
|
|
runs-on: node
|
2024-04-28 15:49:54 +01:00
|
|
|
steps:
|
2024-08-05 18:25:25 +01:00
|
|
|
- uses: https://github.com/appleboy/ssh-action@v1.0.3
|
2024-04-28 15:49:54 +01:00
|
|
|
env:
|
|
|
|
DB_NAME: ${{ secrets.PROD_DB_NAME }}
|
|
|
|
DB_AUTH_USER: ${{ secrets.PROD_DB_AUTH_USER }}
|
|
|
|
DB_AUTH_PASS: ${{ secrets.PROD_DB_AUTH_PASS }}
|
|
|
|
DB_HOST: ${{ secrets.PROD_DB_HOST }}
|
|
|
|
DB_PORT: ${{ secrets.PROD_DB_PORT }}
|
|
|
|
DB_ROOT_HOST: ${{ secrets.PROD_DB_ROOT_HOST }}
|
|
|
|
DB_SYNC: ${{ secrets.PROD_DB_SYNC }}
|
|
|
|
DB_LOGGING: ${{ secrets.PROD_DB_LOGGING }}
|
|
|
|
DB_DATA_LOCATION: ${{ secrets.PROD_DB_DATA_LOCATION }}
|
|
|
|
SERVER_PATH: ${{ secrets.PROD_SSH_SERVER_PATH }}
|
|
|
|
BOT_TOKEN: ${{ secrets.PROD_BOT_TOKEN }}
|
|
|
|
BOT_VER: ${{ vars.PROD_BOT_VER }}
|
|
|
|
BOT_AUTHOR: ${{ vars.PROD_BOT_AUTHOR }}
|
|
|
|
BOT_OWNERID: ${{ vars.PROD_BOT_OWNERID }}
|
|
|
|
BOT_CLIENTID: ${{ vars.PROD_BOT_CLIENTID }}
|
|
|
|
ABOUT_FUNDING: ${{ vars.PROD_ABOUT_FUNDING }}
|
|
|
|
ABOUT_REPO: ${{ vars.PROD_ABOUT_REPO }}
|
|
|
|
CACHE_INTERVAL: ${{ vars.PROD_CACHE_INTERVAL }}
|
|
|
|
with:
|
2024-04-28 16:05:43 +01:00
|
|
|
host: ${{ secrets.PROD_SSH_HOST }}
|
|
|
|
username: ${{ secrets.PROD_SSH_USER }}
|
|
|
|
key: ${{ secrets.PROD_SSH_KEY }}
|
|
|
|
port: ${{ secrets.PROD_SSH_PORT }}
|
2024-04-28 15:49:54 +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,CACHE_INTERVAL
|
|
|
|
script: |
|
2024-04-28 16:26:46 +01:00
|
|
|
source .sshrc \
|
|
|
|
&& cd /home/vylpes/apps/vylbot/vylbot_prod \
|
2024-04-28 15:49:54 +01:00
|
|
|
&& docker compose down \
|
|
|
|
&& (pm2 stop vylbot_prod || true) \
|
|
|
|
&& (pm2 delete vylbot_prod || true) \
|
|
|
|
&& docker compose up -d \
|
|
|
|
&& sleep 10 \
|
2024-06-29 18:26:25 +01:00
|
|
|
&& yarn db:up \
|
|
|
|
&& pm2 start --name vylbot_prod dist/vylbot.js
|