Last active
September 14, 2025 01:02
-
-
Save raviagheda/c69ae5e884f4490b1af656dbd80c00dd to your computer and use it in GitHub Desktop.
Revisions
-
raviagheda revised this gist
May 2, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ # Github Action with EC2 using SSH Check this out on [Dev.to](https://dev.to/raviagheda/github-action-with-ec2-using-ssh-4ej4) ## Configure SSH into aws ec2 -
raviagheda revised this gist
Aug 14, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ jobs: env: PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} HOSTNAME: ${{secrets.SSH_HOST}} USER_NAME: ${{secrets.USER_NAME}} run: | echo "$PRIVATE_KEY" > private_key && chmod 600 private_key -
raviagheda created this gist
Dec 18, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ # Github Action with EC2 using SSH ## Configure SSH into aws ec2 - How to handle SSH keys with ec2-github actions https://zellwk.com/blog/github-actions-deploy/ ### Declare these git secrets - SSH_PRIVATE_KEY - HOST_NAME / IP_ADDRESS - USER_NAME ```yml name: Deploy on: push: branches: [ dev ] jobs: Deploy: name: Deploy to EC2 runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build & Deploy env: PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} HOSTNAME: ${{secrets.SSH_HOST}} USER_NAME: ${secrets.USER_NAME} run: | echo "$PRIVATE_KEY" > private_key && chmod 600 private_key ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} ' # Now we have got the access of EC2 and we will start the deploy . cd /home/ubuntu/<PROJECT_DIRECTORY> && git checkout dev && git fetch --all && git reset --hard origin/dev && git pull origin dev && sudo npm i && sudo npm run build && sudo pm2 stop ./dist/index.js && sudo pm2 start ./dist/index.js ' ```