query sql #44
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: Push-to-EC2 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy to EC2 on main branch push | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the files | |
uses: actions/checkout@v2 | |
with: | |
ref: main | |
- name: Git pull latest changes | |
run: | | |
git fetch origin main | |
git reset --hard origin/main | |
git clean -df | |
- name: Show current branch | |
run: | | |
git branch | |
git status -s | |
- name: Show directory structure | |
run: | | |
tree -L 4 | |
- name: Deploy to Server 1 | |
uses: easingthemes/ssh-deploy@main | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY }} # my PEM | |
REMOTE_HOST: ${{ secrets.HOST_DNS }} # ec2-***-***-***-***.compute-1.amazonaws.com | |
REMOTE_USER: ${{ secrets.USERNAME }} # ubuntu | |
TARGET: ${{ secrets.TARGET_DIR }} # /home/ubuntu/app | |
- 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: | | |
cd app | |
bash deploy.sh |