Update drone script to use rsync #121
9 changed files with 58 additions and 25 deletions
2
.dev.env
2
.dev.env
|
@ -16,6 +16,8 @@ BOT_ENV=4
|
||||||
ABOUT_FUNDING=
|
ABOUT_FUNDING=
|
||||||
ABOUT_REPO=
|
ABOUT_REPO=
|
||||||
|
|
||||||
|
DATA_DIR=
|
||||||
|
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
DB_PORT=3301
|
DB_PORT=3301
|
||||||
DB_NAME=carddrop
|
DB_NAME=carddrop
|
||||||
|
|
66
.drone.yml
66
.drone.yml
|
@ -4,16 +4,31 @@ kind: pipeline
|
||||||
name: deployment
|
name: deployment
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: deploy
|
- name: build
|
||||||
image: appleboy/drone-ssh
|
image: node
|
||||||
|
commands:
|
||||||
|
- npm ci
|
||||||
|
- npm run build
|
||||||
|
- name: test
|
||||||
|
image: node
|
||||||
|
commands:
|
||||||
|
- npm test
|
||||||
|
- name: deploy to prod
|
||||||
|
image: drillster/drone-rsync
|
||||||
Vylpes marked this conversation as resolved
|
|||||||
settings:
|
settings:
|
||||||
host: 192.168.68.120
|
hosts:
|
||||||
username: vylpes
|
- "minisforum.local"
|
||||||
password:
|
user: vylpes
|
||||||
from_secret: ssh_password
|
key:
|
||||||
port: 22
|
from_secret: ssh_key
|
||||||
|
source: .
|
||||||
|
target: ~/apps/card-drop/card-drop_prod
|
||||||
|
recursive: true
|
||||||
script:
|
script:
|
||||||
- sh /home/vylpes/scripts/card-drop/deploy_prod.sh
|
- cd ~/apps/card-drop/card-drop_prod
|
||||||
|
- docker compose --file docker-compose.prod.yml up -d
|
||||||
|
- sleep 10
|
||||||
|
- pm2 restart card-drop_prod || pm2 start --name card-drop_prod dist/bot.js
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
|
@ -25,16 +40,31 @@ kind: pipeline
|
||||||
name: staging
|
name: staging
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: stage
|
- name: build
|
||||||
image: appleboy/drone-ssh
|
image: node
|
||||||
|
commands:
|
||||||
|
- npm ci
|
||||||
|
- npm run build
|
||||||
|
- name: test
|
||||||
|
image: node
|
||||||
|
commands:
|
||||||
|
- npm test
|
||||||
|
- name: deploy to stage
|
||||||
|
image: drillster/drone-rsync
|
||||||
settings:
|
settings:
|
||||||
host: 192.168.68.120
|
hosts:
|
||||||
username: vylpes
|
- "minisforum.local"
|
||||||
password:
|
user: vylpes
|
||||||
from_secret: ssh_password
|
key:
|
||||||
port: 22
|
from_secret: ssh_key
|
||||||
|
source: .
|
||||||
|
target: ~/apps/card-drop/card-drop_stage
|
||||||
|
recursive: true
|
||||||
script:
|
script:
|
||||||
- sh /home/vylpes/scripts/card-drop/deploy_stage.sh
|
- cd ~/apps/card-drop/card-drop_stage
|
||||||
|
- docker compose --file docker-compose.stage.yml up -d
|
||||||
|
- sleep 10
|
||||||
|
- pm2 restart card-drop_stage || pm2 start --name card-drop_stage dist/bot.js
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
|
@ -53,17 +83,13 @@ steps:
|
||||||
commands:
|
commands:
|
||||||
- npm ci
|
- npm ci
|
||||||
- npm run build
|
- npm run build
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
image: node
|
image: node
|
||||||
commands:
|
commands:
|
||||||
- npm ci
|
|
||||||
- npm test
|
- npm test
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- main
|
|
||||||
- develop
|
|
||||||
- hotfix/*
|
- hotfix/*
|
||||||
- feature/*
|
- feature/*
|
||||||
- renovate/*
|
- renovate/*
|
||||||
|
|
|
@ -16,6 +16,8 @@ BOT_ENV=1
|
||||||
ABOUT_FUNDING=
|
ABOUT_FUNDING=
|
||||||
ABOUT_REPO=
|
ABOUT_REPO=
|
||||||
|
|
||||||
|
DATA_DIR=/home/vylpes/appdata/card-drop/card-drop_prod
|
||||||
|
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
DB_PORT=3321
|
DB_PORT=3321
|
||||||
DB_NAME=carddrop
|
DB_NAME=carddrop
|
||||||
|
|
|
@ -16,6 +16,8 @@ BOT_ENV=2
|
||||||
ABOUT_FUNDING=
|
ABOUT_FUNDING=
|
||||||
ABOUT_REPO=
|
ABOUT_REPO=
|
||||||
|
|
||||||
|
DATA_DIR=/home/vylpes/appdata/card-drop/card-drop_stage
|
||||||
|
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
DB_PORT=3311
|
DB_PORT=3311
|
||||||
DB_NAME=carddrop
|
DB_NAME=carddrop
|
||||||
|
|
|
@ -26,7 +26,7 @@ export default class CardMetadataFunction {
|
||||||
private static async FindMetadataJSONs(): Promise<SeriesMetadata[]> {
|
private static async FindMetadataJSONs(): Promise<SeriesMetadata[]> {
|
||||||
const res: SeriesMetadata[] = [];
|
const res: SeriesMetadata[] = [];
|
||||||
|
|
||||||
const seriesJSONs = await glob(path.join(process.cwd(), 'cards', '/**/*.json'));
|
const seriesJSONs = await glob(path.join(process.env.DATA_DIR!, 'cards', '/**/*.json'));
|
||||||
|
|
||||||
for (let jsonPath of seriesJSONs) {
|
for (let jsonPath of seriesJSONs) {
|
||||||
console.log(`Reading file ${jsonPath}`);
|
console.log(`Reading file ${jsonPath}`);
|
||||||
|
|
|
@ -14,6 +14,7 @@ const requiredConfigs: string[] = [
|
||||||
"BOT_OWNERID",
|
"BOT_OWNERID",
|
||||||
"BOT_CLIENTID",
|
"BOT_CLIENTID",
|
||||||
"BOT_ENV",
|
"BOT_ENV",
|
||||||
|
"DATA_DIR",
|
||||||
"DB_HOST",
|
"DB_HOST",
|
||||||
"DB_PORT",
|
"DB_PORT",
|
||||||
"DB_AUTH_USER",
|
"DB_AUTH_USER",
|
||||||
|
@ -39,7 +40,7 @@ Registry.RegisterCommands();
|
||||||
Registry.RegisterEvents();
|
Registry.RegisterEvents();
|
||||||
Registry.RegisterButtonEvents();
|
Registry.RegisterButtonEvents();
|
||||||
|
|
||||||
if (!existsSync(`${process.cwd()}/cards`) && process.env.GDRIVESYNC_AUTO && process.env.GDRIVESYNC_AUTO == 'true') {
|
if (!existsSync(`${process.env.DATA_DIR}/cards`) && process.env.GDRIVESYNC_AUTO && process.env.GDRIVESYNC_AUTO == 'true') {
|
||||||
console.log("Card directory not found, syncing...");
|
console.log("Card directory not found, syncing...");
|
||||||
|
|
||||||
CoreClient.AllowDrops = false;
|
CoreClient.AllowDrops = false;
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default class Reroll extends ButtonEvent {
|
||||||
let image: Buffer;
|
let image: Buffer;
|
||||||
const imageFileName = randomCard.card.path.split("/").pop()!;
|
const imageFileName = randomCard.card.path.split("/").pop()!;
|
||||||
|
|
||||||
image = readFileSync(path.join(process.cwd(), 'cards', randomCard.card.path));
|
image = readFileSync(path.join(process.env.DATA_DIR!, 'cards', randomCard.card.path));
|
||||||
|
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ export default class Drop extends Command {
|
||||||
let image: Buffer;
|
let image: Buffer;
|
||||||
const imageFileName = randomCard.card.path.split("/").pop()!;
|
const imageFileName = randomCard.card.path.split("/").pop()!;
|
||||||
|
|
||||||
image = readFileSync(path.join(process.cwd(), 'cards', randomCard.card.path));
|
image = readFileSync(path.join(process.env.DATA_DIR!, 'cards', randomCard.card.path));
|
||||||
|
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default class Gdrivesync extends Command {
|
||||||
|
|
||||||
CoreClient.AllowDrops = false;
|
CoreClient.AllowDrops = false;
|
||||||
|
|
||||||
exec(`rclone sync card-drop-gdrive: ${process.cwd()}/cards`, async (error: ExecException | null) => {
|
exec(`rclone sync card-drop-gdrive: ${process.env.DATA_DIR}/cards`, async (error: ExecException | null) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
await interaction.editReply(`Error while running sync command. Safe Mode has been activated. Code: ${error.code}`);
|
await interaction.editReply(`Error while running sync command. Safe Mode has been activated. Code: ${error.code}`);
|
||||||
await Config.SetValue('safemode', 'true');
|
await Config.SetValue('safemode', 'true');
|
||||||
|
|
Loading…
Reference in a new issue
This is good and should be how we want it, but maybe we should also move the cards folder externally as well