Skip to content

Commit b3d5aee

Browse files
authored
Add GitHub Actions workflow for EC2 deployment
1 parent 96a9979 commit b3d5aee

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

.github/workflows/deploy-ec2.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Deploy TipsChain Node to EC2
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
workflow_dispatch: # Manual tetikleme için
7+
8+
env:
9+
AWS_REGION: us-east-1
10+
EC2_INSTANCE_ID: i-xxxxxxxxxxxxxxxxx # EC2 Instance ID'niz
11+
SSH_USER: ubuntu
12+
PROJECT_PATH: /home/ubuntu/tips-ecosystem
13+
14+
jobs:
15+
deploy:
16+
runs-on: ubuntu-latest
17+
environment: production
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Configure AWS Credentials
24+
uses: aws-actions/configure-aws-credentials@v4
25+
with:
26+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
27+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28+
aws-region: ${{ env.AWS_REGION }}
29+
30+
- name: Deploy to EC2 via SSH
31+
uses: appleboy/ssh-action@v1.0.3
32+
with:
33+
host: ${{ secrets.EC2_HOST }}
34+
username: ${{ env.SSH_USER }}
35+
key: ${{ secrets.EC2_SSH_KEY }}
36+
script: |
37+
cd ${{ env.PROJECT_PATH }}
38+
git pull origin main
39+
npm ci --production
40+
npm run compile
41+
42+
# Node'u restart et (systemd kullanıyorsanız)
43+
sudo systemctl restart tips-node
44+
45+
# Health check
46+
sleep 10
47+
curl -f http://localhost:8545 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' || exit 1
48+
49+
echo "✅ Deployment completed successfully"

0 commit comments

Comments
 (0)