Skip to content

Commit

Permalink
parent aad4162
Browse files Browse the repository at this point in the history
author Raphael <[email protected]> 1688990184 +0000
committer Raphael Kabo <[email protected]> 1696772947 +0100
gpgsig -----BEGIN PGP SIGNATURE-----

 iQEzBAABCAAdFiEENZJBXR9SBQdfzUlqrBBvvi55RfIFAmUis1MACgkQrBBvvi55
 RfKrfwf+JQ6l4aSSW4gIa95N3rlsceOFm0wLN7QUCEeqocHX96kEblCFUYHb5thP
 GUf5z07XLlAi0pXUhzrK4wajcistv627ObQn3I+XEPdLAqwVAkbcFTdaSBMnSA1/
 8B3Eq/DPxzDCHsdE6ir4q06TPoD42RLSV0fXUaDVyZ3gAXFcZRiDwB/WBf4n8Q3i
 G/JVP2YiLZBQywkjts+SPrwxS7mTwSGoC/iNVtTP22vmYaqlnr01xXNP49UzwpAb
 NaVeS89CEUCbVSdt0YNZQXcTzuXDOcPJt6bK3qzpKaqZ3ZoJgDnioB3MW69Qw5oX
 Fe6wOh88D3NJjmYRY9mugcm7KhWZBw==
 =JuJT
 -----END PGP SIGNATURE-----

parent aad4162
author Raphael <[email protected]> 1688990184 +0000
committer Raphael Kabo <[email protected]> 1696772914 +0100
gpgsig -----BEGIN PGP SIGNATURE-----

 iQEzBAABCAAdFiEENZJBXR9SBQdfzUlqrBBvvi55RfIFAmUiszIACgkQrBBvvi55
 RfId3wf/aAxsJcAKgpMMxUHquO0NOozk2NjAsxiWdgQHjUlBvRDsV2df03In9Tne
 ectxJ/z6irC/D+WYwKppIMRduIxOO/GEJb5Y2vYW6VxBg/khp+jgXRXSrVu9CjLg
 dsgwcmEpsypUnngYxo71YObFe4J7ujjM7lfzRJvqL8LOsWgXMWUNMZG3kFycwMm7
 hBv9MFWEwiXrWQwCKeJ3LocAah+Kl7mN4nMQYg1uIyj/u3mZjzQBBLZQJHljI2lk
 VujuNSBizoKvBl25DKFNt1h9QnBrLH1lPLolglKgWM62iIE823LvMe1XS20LlVyL
 yYsDdIx+YdXLOtb/Jjphrlv9YCRUZg==
 =jHTp
 -----END PGP SIGNATURE-----

Add PM2 deployment config
  • Loading branch information
Raphael authored and lowercasename committed Oct 8, 2023
1 parent a14afed commit a39191f
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 9 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI / Deploy
on:
pull_request:
workflow_dispatch:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Set up known_hosts file
run: |
mkdir -p ~/.ssh/ && touch ~/.ssh/known_hosts
ssh-keyscan -t rsa ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}

- name: Install PM2
run: pnpm install -g pm2

- name: Deploy
run: pnpm run deploy
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

19 changes: 19 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -e

# Set up and redeploy Gathio. Called by `pm2 deploy`.

# PM2 doesn't load the user env, so this gets nvm into the PATH
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
# Set the right Node version
nvm use
# Need to use `development` here else pnpm won't install devDependencies (i.e. tsc)
NODE_ENV=development pnpm install
# This calls `tsc`, which fails due to type errors while we're transitioning
# fully to TypeScript, so we short-circuit it to true to continue running the
# deploy script. TODO: Remove this short-circuit when we've migrated to
# TypeScript and don't expect any more errors.
pnpm build || true
pm2 reload ecosystem.config.cjs production
pm2 save
24 changes: 24 additions & 0 deletions ecosystem.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
apps: [
{
name: "gathio-prod",
script: "pnpm start",
watch: false,
instances: 1,
autorestart: true,
max_restarts: 10,
max_memory_restart: "512M",
},
],

deploy: {
production: {
user: "raphael",
host: "gath.io",
ref: "origin/main",
repo: "[email protected]:lowercasename/gathio",
path: "/home/raphael/gathio-production",
"post-deploy": "./deploy.sh",
},
},
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"start": "node dist/start.js",
"dev": "nodemon -e ts,js --watch src --exec \"pnpm run build ; pnpm run start\"",
"test:dev": "pnpm run dev & wait-on http://localhost:3000 && cypress open --e2e --browser chrome",
"test": "pnpm run build || true && pnpm run start & wait-on http://localhost:3000 && cypress run --e2e --browser chrome"
"test": "pnpm run build || true && pnpm run start & wait-on http://localhost:3000 && cypress run --e2e --browser chrome",
"deploy": "pm2 deploy ecosystem.config.cjs production"
},
"engines": {
"node": ">=16.16.0"
Expand Down

0 comments on commit a39191f

Please sign in to comment.