Skip to content

Commit

Permalink
ci: add deploy AWS
Browse files Browse the repository at this point in the history
  • Loading branch information
conganhhcmus committed Mar 24, 2024
1 parent 4ec3513 commit cbc564a
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,34 @@ jobs:
- if: github.event_name == 'pull_request'
run: echo "${{ github.event.pull_request.title }}" | yarn commitlint

deploy-on-render:
name: Deploy Render
deploy-on-aws:
name: Deploy AWS
env:
RENDER_WEBHOOK: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
HOSTNAME: ${{secrets.SSH_HOST}}
USER_NAME: ${{secrets.USER_NAME}}

environment: Production
if: github.ref == 'refs/heads/master'
needs: [check]
runs-on: ubuntu-latest
steps:
- name: Deploy to Render
run: curl "$RENDER_WEBHOOK"
- name: Deploy to AWS
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/ec2-user/youth-book-api &&
git checkout master &&
git fetch --all &&
git reset --hard origin/master &&
git pull origin master &&
yarn &&
yarn build &&
pm2 stop ./dist/app.js &&
pm2 start ./dist/app.js
'
build:
name: Build
Expand Down

0 comments on commit cbc564a

Please sign in to comment.