Skip to content

Merge pull request #8 from chacachien/feature/improve #52

Merge pull request #8 from chacachien/feature/improve

Merge pull request #8 from chacachien/feature/improve #52

Workflow file for this run

name: Deploy to EC2
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts
- name: Deploy to EC2
run: |
ssh -i ~/.ssh/id_rsa ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} "bash befastapi/Moodle_VirtualAssistant_BE/deploy.sh"
# for private ec2
#name: Deploy to EC2
#
#on:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main
#
#jobs:
# deploy:
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
#
# - uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
#
# - name: Deploy to EC2
# run: |
# aws ssm send-command --instance-ids ${{ secrets.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Deploy application" --parameters "{\"commands\":[\"sudo -u ec2-user bash /home/ec2-user/befastapi/Moodle_VirtualAssistant_BE/deploy.sh\"]}"