Skip to content

Commit 8043430

Browse files
committed
feat: production-deploy actions workflow implementation
1 parent 743ae82 commit 8043430

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed
Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,51 @@
1-
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3-
4-
name: Node.js CI
1+
# This workflow will do a clean installation of node dependencies, build the app dist, transfer the dist files to the remote server and clear the cache on the server
2+
name: Production deploy CI
53

64
on:
75
push:
8-
branches: [ "main" ]
9-
pull_request:
10-
branches: [ "main" ]
6+
branches: ['main']
117

128
jobs:
139
build:
14-
1510
runs-on: ubuntu-latest
1611

1712
strategy:
1813
matrix:
19-
node-version: [18.x, 20.x, 22.x]
20-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
14+
node-version: [20.x, 22.x]
2115

2216
steps:
23-
- uses: actions/checkout@v4
24-
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v4
26-
with:
27-
node-version: ${{ matrix.node-version }}
28-
cache: 'npm'
29-
- run: npm ci
30-
- run: npm run build --if-present
31-
- run: npm test
17+
- uses: actions/checkout@v4
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
cache: 'npm'
23+
24+
# Node dependencies clean install
25+
- name: Node dependencies clean install
26+
run: npm ci
27+
28+
# Build app dist
29+
- name: Build app dist
30+
run: npm run build --if-present
31+
32+
# Add SSH Key
33+
- name: Add SSH key
34+
env:
35+
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
36+
run: |
37+
mkdir -p ~/.ssh
38+
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
39+
chmod 600 ~/.ssh/id_rsa
40+
41+
# Deploy dist files to hosting
42+
- name: Deploy to remove server
43+
run: scp -r -P ${{ secrets.SSH_PORT }} -o strictHostKeyChecking=no ./dist/* ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:www/domain-lookup.${{ vars.DOMAIN }}/public_html
44+
45+
# Clear cache on the server
46+
- name: Clear cache on the server
47+
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -p ${{ secrets.SSH_PORT }} "site-tools-client domain update id=4 flush_cache=1"
48+
49+
# Show link
50+
- name: Show link
51+
run: echo "Deployed! https://domain-lookup.${{ vars.DOMAIN }}"

0 commit comments

Comments
 (0)