-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (39 loc) · 1.32 KB
/
aws-ec2-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: CI/CD Deploy Genius Dashboard Backend/Frontend
on:
push:
branches:
- main
paths-ignore:
- 'README.md'
- '.github/**'
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref_name }}
steps:
# - name: Deploy to CloudFlare
# run: |
# curl -s -X POST "${{ secrets.CLOUD_FLARE_TRIGGER_DEPLOY }}" > /dev/null
- name: Deploy to AWS/EC2
if: (github.ref_name == 'main' || github.ref_name == 'develop')
run: |
echo "${{ secrets.DEPLOY_ACTION_SSH_PRIVATE_KEY }}" > private_key && chmod 600 private_key
BRANCH="${GITHUB_REF#refs/heads/}"
APP_DIR="gnus-dashboard"
ssh -T -o StrictHostKeyChecking=no -i private_key deploy@${{ secrets.DEPLOY_HOSTNAME }} <<-ENDSSH
#!/usr/bin/env bash
set -e
if [ ! -d "gnus-dashboard" ]; then
git clone [email protected]:GeniusVentures/gnus-dashboard.git
fi
cd gnus-dashboard
echo "Branch found is $BRANCH"
git checkout $BRANCH
git fetch --all
git reset --hard origin/$BRANCH
git pull origin $BRANCH
yarn install
yarn run build $BUILD_OPTIONS
pm2 restart gnus-dashboard
ENDSSH