Skip to content

Commit 60b5da8

Browse files
authored
[docs] CD workflow 추가
1 parent f643867 commit 60b5da8

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CD to EC2
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repo
14+
uses: actions/checkout@v3
15+
16+
- name: Add SSH key
17+
run: |
18+
mkdir -p ~/.ssh
19+
echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_rsa
20+
chmod 600 ~/.ssh/id_rsa
21+
ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts
22+
23+
- name: Deploy with SSH
24+
run: |
25+
ssh ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
26+
set -e
27+
cd ${{ secrets.EC2_PATH }}
28+
29+
# Git pull or clone if not yet
30+
if [ ! -d ".git" ]; then
31+
git clone https://github.com/${{ github.repository }} .
32+
else
33+
git pull origin main
34+
fi
35+
EOF

0 commit comments

Comments
 (0)