-
Notifications
You must be signed in to change notification settings - Fork 1
124 lines (111 loc) · 3.38 KB
/
nodejs.yml
File metadata and controls
124 lines (111 loc) · 3.38 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Node CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: npm install, lint
run: |
npm ci
npm run lint
- name: npm test
run: |
npm run test
env:
CI: true
build:
needs: test
runs-on: ubuntu-latest
if: contains('
refs/heads/master
refs/heads/develop
', github.ref)
steps:
- uses: actions/checkout@v3
- name: clear old build files
run: |
rm -rf build.zip build
npm ci
- name: Building
run: |
npm run build
- name: Bundling
run: |
mkdir build && mv .next build/ && mv public build/ && mv dist/* build/ && mv package.json build/ && mv package-lock.json build/ && mv Dockerfile build/ && mv docker-compose.yml build/ && mv pages/ build/ && mv nginx/ build/
zip -q -r build.zip build
- name: Upload build Artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: ./build.zip
- name: Upload deploy script as an artifact
uses: actions/upload-artifact@v3
with:
name: deploy
path: ./deploy_script.sh
- name: Return to original state
run: |
git reset .
git checkout .
rm -rf build
echo "DONE!"
deploy:
needs: build
if: contains('
refs/heads/master
refs/heads/develop
', github.ref)
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v1
with:
name: deploy
path: ./deploy_script.sh
- name: download build artifact
uses: actions/download-artifact@v1
with:
name: build
path: ./build.zip
- name: Set env for develop branch
if: endsWith(github.ref, '/develop')
run: |
echo "::set-env name=HOST::${{ secrets.DEV_HOST }}"
echo "::set-env name=CMS_URL::${{ secrets.DEV_CMS_URL }}"
- name: Set env for master branch
if: endsWith(github.ref, '/master')
run: |
echo "::set-env name=HOST::${{ secrets.PROD_HOST }}"
echo "::set-env name=CMS_URL::${{ secrets.PROD_CMS_URL }}"
- name: copy deploy_file via ssh
uses: appleboy/scp-action@master
env:
HOST: ${{ env.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: ${{ secrets.PORT }}
KEY: ${{ secrets.KEY }}
with:
source: './deploy_script.sh,./build.zip'
target: 'deploy_spotlights'
- name: executing remote ssh commands using ssh
uses: appleboy/ssh-action@master
env:
CMS_URL: ${{ env.CMS_URL }}
BITLY_API_KEY: ${{ secrets.BITLY_API_KEY }}
with:
host: ${{ env.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
envs: CMS_URL,BITLY_API_KEY
script: |
export CMS_URL=$CMS_URL
export BITLY_API_KEY=$BITLY_API_KEY
cd ./deploy_spotlights/deploy_script.sh && chmod +x deploy_script.sh && bash deploy_script.sh