Skip to content

Commit fc28fb6

Browse files
committed
Add GitHub deploy workflow
1 parent 329e687 commit fc28fb6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Deploy to EC2
2+
3+
on:
4+
push:
5+
branches: [main, testing]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Add SSH key
16+
uses: webfactory/[email protected]
17+
with:
18+
ssh-private-key: ${{ secrets.AWS_EC2_SSH_PRIVATE_KEY }}
19+
20+
- name: Copy files and deploy
21+
run: |
22+
ssh -o StrictHostKeyChecking=no ${{ secrets.AWS_EC2_SSH_USERNAME }}@${{ secrets.AWS_EC2_SSH_HOST }} << 'EOF'
23+
cd ~/website
24+
git pull origin main
25+
docker build -t website .
26+
docker stop website || true && docker rm website || true
27+
docker run -d --name website -p 80:3000 website
28+
EOF

0 commit comments

Comments
 (0)