Skip to content

Commit

Permalink
Create github-actions-ec2.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
cristinalare authored Sep 23, 2024
1 parent 8ffe690 commit 0faf6fd
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/github-actions-ec2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
on:
push:
branches:
- main

jobs:
deploy:
name: Deploy to EC2 on master branch push
runs-on: ubuntu-latest

steps:
- name: Checkout the files
uses: actions/checkout@v2

- name: Deploy to Server 1
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY }}
REMOTE_HOST: ${{ secrets.HOST_DNS }}
REMOTE_USER: ${{ secrets.USERNAME }}
TARGET: ${{ secrets.TARGET_DIR }}

- name: Executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_DNS }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
sudo apt-get -y update
sudo apt-get install -y apache2
sudo systemctl start apache2
sudo systemctl enable apache2
cd home
sudo mv * /var/www/html

0 comments on commit 0faf6fd

Please sign in to comment.