-
Notifications
You must be signed in to change notification settings - Fork 1
42 lines (37 loc) · 1.32 KB
/
main.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
name: Deploy to Server
# main 브랜치로 푸시할 때 이 워크플로우 실행
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# GitHub에서 리포지토리 코드를 가져오는 단계
- name: Checkout code
uses: actions/checkout@v2
# 서버로 SSH 연결을 통한 배포
- name: Deploy to server via SSH
env:
SERVER_HOST: ${{secrets.SERVER_HOST}}
SERVER_USER: ${{secrets.SERVER_USER}}
SERVER_SSH_KEY: ${{secrets.SERVER_SSH_KEY}}
if: ${{env.SERVER_HOST && env.SERVER_USER && env.SERVER_SSH_KEY}} # Secret이 존재할 때만 실행
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd ./ArWebAuth/
git pull origin master
npm install
pm2 restart www
- name: Skip deployment in fork
env:
SERVER_HOST: ${{secrets.SERVER_HOST}}
SERVER_USER: ${{secrets.SERVER_USER}}
SERVER_SSH_KEY: ${{secrets.SERVER_SSH_KEY}}
if: ${{env.SERVER_HOST == null || env.SERVER_USER == null || env.SERVER_SSH_KEY == null}}
run: echo "Secrets not found. Skipping deployment."