Merge pull request #21 from dbpedia/feature/UI+CodeCleanup #50
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |