-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (58 loc) · 1.99 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# @format
#trigger a build
name: build
on:
push:
branches:
- dev
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
REPOSITORY_NAME: ${{ secrets.REPOSITORY_NAME}}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 16
uses: actions/setup-node@v1
with:
node-version: '16.0'
- name: Install yarn
run: |
yarn install
env:
CI: true
# - name: Log in to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Get Current Date
# id: date
# run: echo "::set-output name=date::$(date +'%Y-%m-%d--%M-%S')"
# - name: Build Docker Image
# run: docker build . --file Dockerfile --tag $DOCKERHUB_USERNAME/$REPOSITORY_NAME
# - name: Push Docker Image to Docker Hub
# run: docker push $DOCKERHUB_USERNAME/$REPOSITORY_NAME
- name: Deploy package to your instance
uses: appleboy/ssh-action@master
env:
GITHUB_USERNAME: secrets.USERNAME_NAME
GITHUB_TOKEN: ${{ secrets.TOKEN_TOKEN }}
with:
host: ${{ secrets.HOST_IP }}
username: ${{ secrets.HOST_USER }}
password: ${{ secrets.HOST_USER_PWD }}
port: ${{ secrets.HOST_PORT }}
envs: GITHUB_USERNAME, GITHUB_TOKEN
script: |
cd calendarApp/
docker stop $(docker ps -qf expose=8000)
rm -r dinnerwithfriends.api/
git clone https://github.com/workshopapps/dinnerwithfriends.api
cp .env /root/calendarApp/dinnerwithfriends.api
cd dinnerwithfriends.api/
sudo docker build -t thebackend:$(date +'%Y-%m-%d') .
sudo docker run -d -p 8000:8000 thebackend:$(date +'%Y-%m-%d')
echo "refresh the page and check"