Skip to content

Commit 9f641a3

Browse files
committed
.
0 parents  commit 9f641a3

File tree

10 files changed

+2572
-0
lines changed

10 files changed

+2572
-0
lines changed

.github/workflows/node.js.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Build and Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v3
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: '16'
19+
20+
- name: Install Dependencies
21+
run: npm ci
22+
23+
- name: Build Project
24+
run: npm run build
25+
26+
- name: Upload Build Artifact
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: build-files
30+
path: |
31+
dist
32+
ecosystem.config.js
33+
package.json
34+
package-lock.json
35+
36+
deploy:
37+
needs: build
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Download Build Artifact
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: build-files
44+
path: build-files
45+
46+
- name: List downloaded artifact
47+
run: ls -la build-files
48+
49+
- name: Ensure target directory exists on Linode
50+
uses: appleboy/ssh-action@master
51+
with:
52+
host: ${{ secrets.LINODE_HOST }}
53+
username: ${{ secrets.LINODE_USER }}
54+
key: ${{ secrets.LINODE_SSH_KEY }}
55+
script: |
56+
mkdir -p /home/puppeteer-user/candycomp-location-correction
57+
58+
- name: Copy Build Files to Linode Server
59+
uses: appleboy/scp-action@master
60+
with:
61+
host: ${{ secrets.LINODE_HOST }}
62+
username: ${{ secrets.LINODE_USER }}
63+
key: ${{ secrets.LINODE_SSH_KEY }}
64+
source: 'build-files/.'
65+
target: '/home/puppeteer-user/candycomp-location-correction/'
66+
strip_components: 1
67+
68+
- name: Create .env file on Linode
69+
uses: appleboy/ssh-action@master
70+
with:
71+
host: ${{ secrets.LINODE_HOST }}
72+
username: ${{ secrets.LINODE_USER }}
73+
key: ${{ secrets.LINODE_SSH_KEY }}
74+
script: |
75+
cat <<'EOF' > /home/puppeteer-user/candycomp-location-correction/.env
76+
PORT=${{ secrets.PORT }}
77+
GMAPS_API_KEY=${{ secrets.GMAPS_API_KEY }}
78+
USPS_TOKEN_URL=${{ secrets.USPS_TOKEN_URL }}
79+
USPS_ADDRESS_URL=${{ secrets.USPS_ADDRESS_URL }}
80+
USPS_CONSUMER_KEY=${{ secrets.USPS_CONSUMER_KEY }}
81+
USPS_CONSUMER_SECRET=${{ secrets.USPS_CONSUMER_SECRET }}
82+
NODE_ENV=production
83+
EOF
84+
85+
- name: List deployment directory contents
86+
uses: appleboy/ssh-action@master
87+
with:
88+
host: ${{ secrets.LINODE_HOST }}
89+
username: ${{ secrets.LINODE_USER }}
90+
key: ${{ secrets.LINODE_SSH_KEY }}
91+
script: 'ls -la /home/puppeteer-user/candycomp-location-correction/'
92+
93+
- name: Install Node Modules on Linode
94+
uses: appleboy/ssh-action@master
95+
with:
96+
host: ${{ secrets.LINODE_HOST }}
97+
username: ${{ secrets.LINODE_USER }}
98+
key: ${{ secrets.LINODE_SSH_KEY }}
99+
script: |
100+
cd /home/puppeteer-user/candycomp-location-correction
101+
npm ci
102+
103+
- name: Start or Reload and Save PM2 Process on Linode
104+
uses: appleboy/ssh-action@master
105+
with:
106+
host: ${{ secrets.LINODE_HOST }}
107+
username: ${{ secrets.LINODE_USER }}
108+
key: ${{ secrets.LINODE_SSH_KEY }}
109+
script: |
110+
cd /home/puppeteer-user/candycomp-location-correction
111+
pm2 startOrReload ecosystem.config.js
112+
pm2 save

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules
2+
minify.js
3+
minified.txt
4+
.local.env
5+
.production.env
6+
.env

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 150,
6+
"tabWidth": 4,
7+
"useTabs": true,
8+
"bracketSpacing": true,
9+
"arrowParens": "avoid"
10+
}

.vscode/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true,
4+
"files.exclude": {
5+
"**/.git": true,
6+
"**/.svn": true,
7+
"**/.hg": true,
8+
"**/.DS_Store": true,
9+
"**/Thumbs.db": true,
10+
"**/CVS": true,
11+
"**/.retool_types/**": true,
12+
"**/*tsconfig.json": true,
13+
".cache": true,
14+
"retool.config.json": true
15+
},
16+
"git.ignoreLimitWarning": true,
17+
"[typescript]": {
18+
"editor.defaultFormatter": "vscode.typescript-language-features"
19+
}
20+
}

ecosystem.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//ecosystem.config.js
2+
3+
module.exports = {
4+
apps: [
5+
{
6+
name: 'candycomp-location-correction',
7+
script: 'dist/server.js',
8+
exec_mode: 'cluster',
9+
watch: false,
10+
env: {
11+
NODE_ENV: 'production',
12+
},
13+
},
14+
],
15+
};

0 commit comments

Comments
 (0)