Skip to content

Version 2

Version 2 #3

Workflow file for this run

name: Deploy to EC2
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy nginx to EC2
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
sudo apt-get install -y -q nginx
sudo tee /var/www/html/index.html > /dev/null <<'EOF'
<!DOCTYPE html>
<html>
<head><title>Hello World</title></head>
<body>
<h1>Hello World from EC2!</h1>
<p>Deployed via GitHub Actions.</p>
</body>
</html>
EOF
sudo systemctl enable nginx
sudo systemctl start nginx