From d6f326466fb5dae8ba75d42cb5b96f2af062cb7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20J=C5=AFna?= Date: Sat, 26 Oct 2024 14:12:50 +0200 Subject: [PATCH] add deployment --- .github/workflows/main.yml | 39 ++++++++++++++++++++++++++++++++++++++ config/default.json | 2 +- package.json | 4 +++- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e864bdc --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,39 @@ +name: Main CI + +on: + push: + branches: [ deployment ] +# branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Copy files to prod server + uses: appleboy/scp-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USER }} + key: ${{ secrets.SSH_KEY }} + port: ${{ secrets.SSH_PORT }} + source: "." + target: ${{ secrets.PATH }} + + - name: Restart + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USER }} + key: ${{ secrets.SSH_KEY }} + port: ${{ secrets.SSH_PORT }} + envs: NODE_ENV,CALENDAR_ID,EARNINGS_HEADSUP_DAYS,GCP_CLIENT_EMAIL,GCP_PRIVATE_KEY + script: | + export NVM_DIR=~/.nvm + source ~/.nvm/nvm.sh + cd ${{ secrets.PATH }} + rm -rf .git + pnpm i + pnpm run prod:stop + NODE_ENV=${{ secrets.NODE_ENV }} CALENDAR_ID=${{ secrets.CALENDAR_ID }} EARNINGS_HEADSUP_DAYS=${{ secrets.EARNINGS_HEADSUP_DAYS }} GCP_CLIENT_EMAIL=${{ secrets.GCP_CLIENT_EMAIL }} GCP_PRIVATE_KEY=${{ secrets.GCP_PRIVATE_KEY }} npm run prod:start diff --git a/config/default.json b/config/default.json index 835faa6..1561683 100644 --- a/config/default.json +++ b/config/default.json @@ -1,6 +1,6 @@ { "calendarId": "", - "symbols": "AAPL,AMZN", + "symbols": "AAPL,AMZN,MSFT,HAS,MCD,NVDA,AMD,DELL,PG,COST,MAT,TXRH,SPGI,TWLO,INTU,OKTA,ADBE,CROX,NET,AVGO,DDOG,CP,ZM,DOCU,AI,OXY,ROKU,NKE,GOOG,MDB,KO,SMCI,F,EA,META,TSLA,CAT,STZ,MA,V,TSM,DOCU,WMT,JPM,TGT,CMG", "earningsHeadsupDays": 0, "gcpCredentials": { "clientEmail": "", diff --git a/package.json b/package.json index 55a986a..b17e971 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,10 @@ "type": "module", "scripts": { "accept-calendar-invitation": "npx tsx ./commands/accept-calendar-invitation.command.ts", - "start": "npx tsx app/app.ts", + "prod:start": "forever start -a --uid trading-calendar -c 'npx tsx' ./app/app.ts", + "prod:stop": "forever stop trading-calendar", "single": "npx tsx app/app.ts --single", + "start": "npx tsx app/app.ts", "sync-cpi-events": "npx tsx ./commands/sync-cpi-events.command.ts", "sync-dividend-events": "npx tsx ./commands/sync-dividend-events.command.ts", "sync-earnings-events": "npx tsx ./commands/sync-earnings-events.command.ts",