-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (66 loc) · 2.23 KB
/
Copy pathdeploy.common.yml
File metadata and controls
78 lines (66 loc) · 2.23 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
name: Common Deploy Setup
on:
workflow_call:
inputs:
ssh_destination_dir:
description: 'The destination directory for remote server'
required: true
type: string
ssh_deployment_url:
description: 'The final URL which the deployment will be available at'
required: true
type: string
is_production:
description: 'Decide wether deployment will require administrators permission'
required: false
type: boolean
secrets:
SSH_PRIVATE_KEY:
required: true
AWS_REMOTE_IP:
required: true
AWS_USER:
required: true
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.is_production && 'production' || 'staging' }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Use Node.js version from .nvmrc
id: node_version
working-directory: ./apps/widget-thr808
run: |
NODE_VERSION=$(cat .nvmrc)
echo "Using Node.js version $NODE_VERSION"
echo "NODE_VERSION=${NODE_VERSION}" >> $GITHUB_ENV
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn install
working-directory: ./apps/widget-thr808
- name: Build the React App
run: yarn build
working-directory: ./apps/widget-thr808
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan ${{ secrets.AWS_REMOTE_IP }} >> ~/.ssh/known_hosts
- name: Install rsync
run: sudo apt-get install -y rsync
- name: Deploy to Staging
run: |
echo "Deploying to Staging"
rsync -avz --no-times --no-perms -e "ssh -o StrictHostKeyChecking=no" dist/ ${{secrets.AWS_USER}}@${{secrets.AWS_REMOTE_IP}}:${{inputs.ssh_destination_dir}}
working-directory: ./apps/widget-thr808
- name: Post deployment steps
run: |
echo "Deployment url: ${{ inputs.ssh_deployment_url }}"
- name: Cleanup SSH Keys
run: shred -u ~/.ssh/id_rsa