diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 94fb8e5..3da5c9e 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -12,6 +12,7 @@ on: - killua-bot - discord-court-bot - hugo-chat + - cors jobs: build: diff --git a/ci/build.sh b/ci/build.sh index 92ae531..f8ab41b 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -1,41 +1,67 @@ #/usr/bin/env bash -set -eu +set -euo pipefail APP="$1" if [ "$APP" = "hugo-chat" ]; then - git clone "https://github.com/C0RR1T/HugoChat.git" ../app - cd ../app - - CURRENT_COMMIT=$(git rev-parse HEAD | cut -c1-8) - echo "Latest commit of $APP is $CURRENT_COMMIT" - - IMAGE_PREFIX="docker.nilstrieb.dev/hugo-chat" - SERVER_FULL_NAME="$IMAGE_PREFIX-server:$CURRENT_COMMIT" - CLIENT_FULL_NAME="$IMAGE_PREFIX-client:$CURRENT_COMMIT" - - cd ./HugoServer - echo "Building server" - docker build . -t "$SERVER_FULL_NAME" - docker push "$SERVER_FULL_NAME" - - cd ../hugo-client - echo "Building client" - docker build . -t "$CLIENT_FULL_NAME" - docker push "$CLIENT_FULL_NAME" - - exit 0 + REPO="https://github.com/C0RR1T/HugoChat.git" +elif [ "$APP" = "cors" ]; then + REPO="https://github.com/nilstrieb-lehre/davinci-cors.git" +else + REPO="https://github.com/Nilstrieb/$APP.git" fi -echo "Checking out $APP" - -git clone "https://github.com/Nilstrieb/$APP.git" ../app +echo "Checking out $REPO" +git clone "$REPO" ../app cd ../app CURRENT_COMMIT=$(git rev-parse HEAD | cut -c1-8) echo "Latest commit of $APP is $CURRENT_COMMIT" +if [ "$APP" = "hugo-chat" ]; then + IMAGE_PREFIX="docker.nilstrieb.dev/hugo-chat" + SERVER_FULL_NAME="$IMAGE_PREFIX-server:$CURRENT_COMMIT" + CLIENT_FULL_NAME="$IMAGE_PREFIX-client:$CURRENT_COMMIT" + + pushd ./HugoServer + echo "Building server" + docker build . -t "$SERVER_FULL_NAME" + docker push "$SERVER_FULL_NAME" + popd + + pushd ./hugo-client + echo "Building client" + docker build . -t "$CLIENT_FULL_NAME" + docker push "$CLIENT_FULL_NAME" + popd + + exit 0 +fi + +if [ "$APP" = "cors" ]; then + IMAGE_PREFIX="docker.nilstrieb.dev/cors-school" + SERVER_FULL_NAME="$IMAGE_PREFIX-server:$CURRENT_COMMIT" + CLIENT_FULL_NAME="$IMAGE_PREFIX-client:$CURRENT_COMMIT" + BOT_FULL_NAME="$IMAGE_PREFIX-bot:$CURRENT_COMMIT" + + pushd ./react-frontend + echo "Building frontend" + docker build -t "$CLIENT_FULL_NAME" . + docker push "$SERVER_FULL_NAME" + popd + + pushd ./rust + echo "Building bot" + docker build -t "$SERVER_FULL_NAME" -f Dockerfile.server . + docker push "$SERVER_FULL_NAME" + docker build -t "$BOT_FULL_NAME" -f Dockerfile.bot . + docker push "$BOT_FULL_NAME" + popd + + exit 0 +fi + IMAGE_PREFIX="docker.nilstrieb.dev/$APP" IMAGE_FULL_NAME="$IMAGE_PREFIX:$CURRENT_COMMIT"