From 0faf6fd986c944d5e9ae3f0d6944bf23e10e4bef Mon Sep 17 00:00:00 2001 From: Cristina Lare <100524474+cristinalare@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:48:38 +0300 Subject: [PATCH] Create github-actions-ec2.yml --- .github/workflows/github-actions-ec2.yml | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/github-actions-ec2.yml diff --git a/.github/workflows/github-actions-ec2.yml b/.github/workflows/github-actions-ec2.yml new file mode 100644 index 0000000..8ee92e0 --- /dev/null +++ b/.github/workflows/github-actions-ec2.yml @@ -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