-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (71 loc) · 3.23 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Docker Image CI
env:
DOCKER_IMAGE_NAME: dbpedia/dbpedia-chatbot-backend
DOCKER_CONTAINER_WEBHOOK: dbpedia-chatbot-webhook
DOCKER_CONTAINER_RDF_VIZ: dbpedia-chatbot-rdf-viz
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get current version
run: >
echo "X_APP_VERSION=$(cat ./Webhook/main.py | grep -o 'version="[^"]*"' | cut -d '"' -f2)" >> $GITHUB_ENV
- name: Build the Docker image for deployment
run: |
echo "changing to /webhook"
cd Webhook
echo "building webhook service"
docker build --tag "$DOCKER_IMAGE_NAME-webhook:latest" .
echo "changing to rdf_visualization"
cd ../rdf_visualization
echo "building rdf viz service"
docker build --tag "$DOCKER_IMAGE_NAME-rdfviz:latest" .
- name: Tag images with specific version
run: |
echo "tagging webhook image"
docker tag "$DOCKER_IMAGE_NAME-webhook:latest" "$DOCKER_IMAGE_NAME-webhook:$X_APP_VERSION"
echo "tagging rdf viz image"
docker tag "$DOCKER_IMAGE_NAME-rdfviz:latest" "$DOCKER_IMAGE_NAME-rdfviz:$X_APP_VERSION"
- name: Docker Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DBP_DOCKERHUB_CREDENTIAL_USERNAME }}
password: ${{ secrets.DBP_DOCKERHUB_CREDENTIAL_TOKEN_PUSHIMAGES }}
- name: Push webhook image with latest version
run: docker push "$DOCKER_IMAGE_NAME-webhook:latest"
- name: Push webhook image with specific version
run: docker push "$DOCKER_IMAGE_NAME-webhook:$X_APP_VERSION"
- name: Push rdf viz image with latest version
run: docker push "$DOCKER_IMAGE_NAME-rdfviz:latest"
- name: Push rdf viz image with specific version
run: docker push "$DOCKER_IMAGE_NAME-rdfviz:$X_APP_VERSION"
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: SSH into server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
envs: DOCKER_IMAGE_NAME,DOCKER_CONTAINER_WEBHOOK, DOCKER_CONTAINER_RDF_VIZ
script: |
docker stop "$DOCKER_CONTAINER_WEBHOOK" || true && docker rm "$DOCKER_CONTAINER_WEBHOOK" || true
echo "stop container rdfviz"
docker stop "$DOCKER_CONTAINER_RDF_VIZ" || true && docker rm "$DOCKER_CONTAINER_RDF_VIZ" || true
echo "Pulling image: $DOCKER_IMAGE_NAME-webhook"
docker pull $DOCKER_IMAGE_NAME-webhook:latest
echo "Pulling image: $DOCKER_IMAGE_NAME-rdfviz"
docker pull $DOCKER_IMAGE_NAME-rdfviz:latest
echo "Starting container: $DOCKER_CONTAINER_WEBHOOK"
docker run --restart=always -d -p 40194:8080 --name "$DOCKER_CONTAINER_WEBHOOK" "$DOCKER_IMAGE_NAME-webhook:latest"
echo "Starting container: $DOCKER_CONTAINER_RDF_VIZ"
docker run --restart=always -d -p 40193:8080 --name "$DOCKER_CONTAINER_RDF_VIZ" "$DOCKER_IMAGE_NAME-rdfviz:latest"