emails sent on certain condition (duration) #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |