Add deployment scripts
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
58d1541e47
commit
6e8fb80836
8 changed files with 145 additions and 2 deletions
71
.drone.yml
Normal file
71
.drone.yml
Normal file
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
|
||||
kind: pipeline
|
||||
name: deployment
|
||||
|
||||
steps:
|
||||
- name: deploy
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host: 192.168.68.121
|
||||
username: vylpes
|
||||
password:
|
||||
from_secret: ssh_password
|
||||
port: 22
|
||||
script:
|
||||
- sh /home/vylpes/scripts/card-drop/deploy_prod.sh
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
name: staging
|
||||
|
||||
steps:
|
||||
- name: stage
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host: 192.168.68.121
|
||||
username: vylpes
|
||||
password:
|
||||
from_secret: ssh_password
|
||||
port: 22
|
||||
script:
|
||||
- sh /home/vylpes/scripts/card-drop/deploy_stage.sh
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- develop
|
||||
event:
|
||||
- push
|
||||
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
name: integration
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: node
|
||||
commands:
|
||||
- yarn install --frozen-lockfile
|
||||
- yarn build
|
||||
|
||||
- name: test
|
||||
image: node
|
||||
commands:
|
||||
- yarn install --frozen-lockfile
|
||||
- yarn test
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
- develop
|
||||
- hotfix/*
|
||||
- feature/*
|
||||
- renovate/*
|
||||
event:
|
||||
- push
|
|
@ -0,0 +1,10 @@
|
|||
CREATE TABLE `inventory` (
|
||||
`Id` varchar(255) NOT NULL,
|
||||
`WhenCreated` datetime NOT NULL,
|
||||
`WhenUpdated` datetime NOT NULL,
|
||||
`UserId` varchar(255) NOT NULL,
|
||||
`CardNumber` varchar(255) NOT NULL,
|
||||
`Quantity` int NOT NULL,
|
||||
`ClaimId` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`Id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
@ -7,9 +7,10 @@
|
|||
"clean": "rm -rf node_modules/ dist/",
|
||||
"build": "tsc",
|
||||
"start": "node ./dist/bot.js",
|
||||
"test": "jest",
|
||||
"test": "jest --passWithNoTests",
|
||||
"db:up": "typeorm migration:run -d dist/database/dataSources/appDataSource.js",
|
||||
"db:down": "typeorm migration:revert -d dist/database/dataSources/appDataSource.js",
|
||||
"db:create": "typeorm migration:create ./src/database/migrations/app/new",
|
||||
"release": "np --no-publish"
|
||||
},
|
||||
"repository": "https://gitea.vylpes.xyz/External/card-drop.git",
|
||||
|
|
23
scripts/deploy_prod.sh
Normal file
23
scripts/deploy_prod.sh
Normal file
|
@ -0,0 +1,23 @@
|
|||
#! /bin/bash
|
||||
|
||||
export PATH="$HOME/.yarn/bin:$PATH"
|
||||
export PATH="$HOME/.nodeuse/bin:$PATH"
|
||||
|
||||
export BOT_TOKEN=$(cat $HOME/scripts/card-drop/prod_key.txt)
|
||||
|
||||
cd ~/apps/card-drop/card-drop_prod \
|
||||
&& git checkout main \
|
||||
&& git fetch \
|
||||
&& git pull \
|
||||
&& docker compose --file docker-compose.prod.yml down \
|
||||
&& (pm2 stop card-drop_prod || true) \
|
||||
&& (pm2 delete card-drop_prod || true) \
|
||||
&& cp .prod.env .env \
|
||||
&& yarn clean \
|
||||
&& yarn install --frozen-lockfile \
|
||||
&& yarn build \
|
||||
&& docker compose --file docker-compose.prod.yml up -d \
|
||||
&& echo "Sleeping for 10 seconds to let database load..." \
|
||||
&& sleep 10 \
|
||||
&& yarn run db:up \
|
||||
&& NODE_ENV=production pm2 start --name card-drop_prod dist/bot.js
|
23
scripts/deploy_stage.sh
Normal file
23
scripts/deploy_stage.sh
Normal file
|
@ -0,0 +1,23 @@
|
|||
#! /bin/bash
|
||||
|
||||
export PATH="$HOME/.yarn/bin:$PATH"
|
||||
export PATH="$HOME/.nodeuse/bin:$PATH"
|
||||
|
||||
export BOT_TOKEN=$(cat $HOME/scripts/card-drop/stage_key.txt)
|
||||
|
||||
cd ~/apps/card-drop/card-drop_stage \
|
||||
&& git checkout develop \
|
||||
&& git fetch \
|
||||
&& git pull \
|
||||
&& docker compose --file docker-compose.stage.yml down \
|
||||
&& (pm2 stop card-drop_stage || true) \
|
||||
&& (pm2 delete card-drop_stage || true) \
|
||||
&& cp .stage.env .env \
|
||||
&& yarn clean \
|
||||
&& yarn install --frozen-lockfile \
|
||||
&& yarn build \
|
||||
&& docker compose --file docker-compose.stage.yml up -d \
|
||||
&& echo "Sleeping for 10 seconds to let database load..." \
|
||||
&& sleep 10 \
|
||||
&& yarn run db:up \
|
||||
&& NODE_ENV=production pm2 start --name card-drop_stage dist/bot.js
|
|
@ -6,7 +6,7 @@ dotenv.config();
|
|||
const CardDataSource = new DataSource({
|
||||
type: "sqlite",
|
||||
database: process.env.DB_CARD_FILE!,
|
||||
synchronize: process.env.DB_SYNC == "true",
|
||||
synchronize: true,
|
||||
logging: process.env.DB_LOGGING == "true",
|
||||
entities: [
|
||||
"dist/database/entities/card/**/*.js",
|
||||
|
|
15
src/database/migrations/app/0.1/1693769942868-CreateBase.ts
Normal file
15
src/database/migrations/app/0.1/1693769942868-CreateBase.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||
import MigrationHelper from "../../../../helpers/MigrationHelper"
|
||||
|
||||
export class CreateBase1693769942868 implements MigrationInterface {
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
MigrationHelper.Up('1693769942868-CreateBase', '0.1', [
|
||||
"01-table/Inventory",
|
||||
], queryRunner);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue