-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (78 loc) ยท 2.73 KB
/
develop.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: havit-server-dev
on:
push:
branches: [develop]
jobs:
build:
env:
PORT: ${{ secrets.PORT }}
MONGODB_URI_DEV: ${{ secrets.MONGODB_URI_DEV }}
MONGODB_URI_PROD: ${{ secrets.MONGODB_URI_PROD }}
REGION: ${{ secrets.REGION }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Create .env file
run: |
touch .env
echo MONGODB_URI_DEV=${{ secrets.MONGODB_URI_DEV }} >> .env
echo MONGODB_URI_PROD=${{ secrets.MONGODB_URI_PROD }} >> .env
echo PORT=${{ secrets.PORT }} >> .env
echo DEV_PORT=${{ secrets.DEV_PORT }} >> .env
echo DOCKERFILE=Dockerfile.dev >> .env
cat .env
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: 'fcm-admin-credentials.json'
json: ${{ secrets.FIREBASE_JSON_DEV }}
dir: 'src/'
- name: Install dependencies
run: yarn
- name: Run build
run: yarn build
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{secrets.DOCKER_HUB_USERNAME}}
password: ${{secrets.DOCKER_HUB_TOKEN}}
- name: build and tagging release to DockerHub
env:
NAME: ${{secrets.DOCKER_HUB_USERNAME}}
REPO: havit-push
run: |
shortHash=$(git rev-parse --short ${{ github.sha }})
docker build -t $REPO -f Dockerfile.dev .
docker tag $REPO:latest $NAME/$REPO:latest
docker tag $REPO:latest $NAME/$REPO:dev
docker tag $REPO:latest $NAME/$REPO:dev-$shortHash
docker push $NAME/$REPO:latest
docker push $NAME/$REPO:dev
docker push $NAME/$REPO:dev-$shortHash
- name: Run Deploy Script
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_IP }}
username: ${{ secrets.REMOTE_SSH_ID }}
key: ${{ secrets.REMOTE_SSH_KEY }}
port: ${{ secrets.REMOTE_SSH_PORT }}
script: |
cd /opt/havit/docker
sudo /opt/havit/docker/dev-deploy.sh
- name: action-slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: Github Action Push Server
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_DEV }} # required
if: always() # Pick up events even if the job fails or is canceled.