Skip to content

test

test #4

Workflow file for this run

name: Deploy to EC2
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v3
# Step 2: Set up SSH private key
- name: Set up SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.EC2_SSH_PRIVATE_KEY }}
# Step 3: Add EC2 host to known_hosts
- name: Add EC2 host to known_hosts
run: |
mkdir -p ~/.ssh
chmod 700 ~/.ssh # Ensure proper permissions for the SSH folder
ssh-keyscan -H ${{ secrets.EC2_PUBLIC_IP }} >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts # Ensure proper permissions for known_hosts file
# Step 4: Deploy to EC2 using rsync
- name: Deploy to EC2 using rsync
run: |
rsync -avz -e "ssh" ./ ec2-user@${{ secrets.EC2_PUBLIC_IP }}:/home/ec2-user/let_me_know