-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (43 loc) · 1.26 KB
/
deploy.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
name: Deploy to EC2
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE20: true
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Build the app
run: npm run build
steps:
- name: Print Secrets
run: |
echo "EC2 Host: ${{ secrets.EC2_HOST }}"
echo "EC2 User: ${{ secrets.EC2_USER }}"
echo "EC2 SSH Key: |"
echo "${{ secrets.EC2_SSH_KEY }}"
echo "This is just for debugging purposes. Make sure to remove it later."
env:
EC2_SSH_KEY: ${{ secrets.EC2_SSH_KEY }}
- name: Copy files to EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
port: 22
source: "build/*"
target: "/var/www/html/"
- name: Restart Nginx
run: |
ssh -i ${{ secrets.EC2_SSH_KEY }} -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} "sudo systemctl reload nginx"