-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (36 loc) · 1.62 KB
/
annotation_build.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
name: Annotation CI/CD
on:
#workflow_dispatch:
push:
branches: [ develop ]
paths:
- 'app/annotation-service/**'
jobs:
build-and-push:
runs-on: ubuntu-latest
env:
working-directory: ./app/annotation-service
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build Docker image
working-directory: ${{env.working-directory}}
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-annotation:${{ github.run_number }} .
- name: Login to Docker Hub
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Push Docker image
run: |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-annotation:${{ github.run_number }}
# SSH and Deploy to Server
- name: Setup SSH Agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy to Server
run: |
ssh -o StrictHostKeyChecking=no root@${{ secrets.SERVER_IP }} \
"docker pull ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-annotation:${{ github.run_number }} && \
docker stop gamelounge-annotation || true && \
docker rm gamelounge-annotation || true && \
docker run -d --name gamelounge-annotation -p 8081:8080 -e SPRING_DATASOURCE_URL="jdbc:postgresql://${{ secrets.SERVER_IP }}:5433/annotation" -e SPRING_DATASOURCE_USERNAME="annotation" -e SPRING_DATASOURCE_PASSWORD="${{ secrets.DOCKERHUB_PASSWORD }}" ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-annotation:${{ github.run_number }}"