-
Notifications
You must be signed in to change notification settings - Fork 5
54 lines (54 loc) · 1.59 KB
/
node.js.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: App or Dev Build and Deploy
on:
push:
branches: [main, dev]
jobs:
test:
runs-on: ubuntu-latest
env:
TEST_USERNAME: ${{ secrets.TEST_USERNAME }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "20"
- name: Install Dependencies
run: npm install
- name: Run Tests
run: npm test
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "20"
- name: Install Dependencies
run: npm install
- name: Build
run: |
if [ "${{ github.ref }}" == "refs/heads/dev" ]; then
npm run build:dev
else
npm run build:prod
fi
- name: Set Target Directory
run: |
if [ "${{ github.ref }}" == "refs/heads/dev" ]; then
echo "TARGET_DIR=/home/ec2-user/www-dev" >> $GITHUB_ENV
else
echo "TARGET_DIR=/home/ec2-user/www" >> $GITHUB_ENV
fi
- name: Deploy to Server
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOYMENT_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan 44.208.84.199 >> ~/.ssh/known_hosts
scp -i ~/.ssh/id_rsa -r ./dist/* [email protected]:$TARGET_DIR
env:
DEPLOY_KEY: ${{ secrets.DEPLOYMENT_KEY }}