diff --git a/.github/workflows/docker_img.yml b/.github/workflows/docker_img.yml index ca775d8173817d38309f1f9d41b31ba87d369341..2e93ac72d9f824471ace885690156f6a844b3f0b 100644 --- a/.github/workflows/docker_img.yml +++ b/.github/workflows/docker_img.yml @@ -12,6 +12,9 @@ jobs: MATAMO_URL_PROD: 'https://stats.humanbrainproject.eu/' PRODUCTION: 'true' DOCKER_REGISTRY: 'docker-registry.ebrains.eu/siibra/' + SIIBRA_API_STABLE: 'https://siibra-api-stable.apps.hbp.eu/v1_0"' + SIIBRA_API_RC: 'https://siibra-api-rc.apps.hbp.eu/v1_0"' + SIIBRA_API_LATEST: 'https://siibra-api-latest.apps-dev.hbp.eu/v1_0"' steps: - uses: actions/checkout@v2 @@ -21,16 +24,23 @@ jobs: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV - if [[ "$GITHUB_REF" == 'refs/heads/master' ]] || [[ "$GITHUB_REF" == 'refs/heads/staging' ]] + if [[ "$GITHUB_REF" == 'refs/heads/master' ]] then - echo "Either master or staging, using prod env..." + echo "Either master, using prod env..." echo "MATAMO_URL=${{ env.MATAMO_URL_PROD }}" >> $GITHUB_ENV echo "MATOMO_ID=${{ env.MATOMO_ID_PROD }}" >> $GITHUB_ENV - + echo "BS_REST_URL=${{ env.SIIBRA_API_STABLE }}" >> $GITHUB_ENV + elif [[ "$GITHUB_REF" == 'refs/heads/staging' ]] + then + echo "Either staging, using staging env..." + echo "MATAMO_URL=${{ env.MATAMO_URL_PROD }}" >> $GITHUB_ENV + echo "MATOMO_ID=${{ env.MATOMO_ID_PROD }}" >> $GITHUB_ENV + echo "BS_REST_URL=${{ SIIBRA_API_RC }}" >> $GITHUB_ENV else echo "Using dev env..." echo "MATAMO_URL=${{ env.MATAMO_URL_DEV }}" >> $GITHUB_ENV echo "MATOMO_ID=${{ env.MATOMO_ID_DEV }}" >> $GITHUB_ENV + echo "BS_REST_URL=${{ SIIBRA_API_LATEST }}" >> $GITHUB_ENV fi - name: 'Set version variable' @@ -52,6 +62,7 @@ jobs: --build-arg VERSION=$VERSION \ --build-arg MATAMO_URL=$MATAMO_URL \ --build-arg MATAMO_ID=$MATAMO_ID \ + --build-arg BS_REST_URL=$BS_REST_URL \ -t $DOCKER_BUILT_TAG \ . echo "Successfully built $DOCKER_BUILT_TAG" @@ -88,11 +99,13 @@ jobs: echo "OKD_URL=https://okd.hbp.eu:443" >> $GITHUB_ENV echo "OKD_SECRET=${{ secrets.OKD_PROD_SECRET }}" >> $GITHUB_ENV echo "OKD_PROJECT=interactive-viewer" >> $GITHUB_ENV + echo "PATH_POSTFIX=" >> $GITHUB_ENV echo "Deploy on prod cluster..." else echo "OKD_URL=https://okd-dev.hbp.eu:443" >> $GITHUB_ENV echo "OKD_SECRET=${{ secrets.OKD_DEV_SECRET }}" >> $GITHUB_ENV echo "OKD_PROJECT=interactive-atlas-viewer" >> $GITHUB_ENV + echo "PATH_POSTFIX=-dev" >> $GITHUB_ENV echo "Deploy on dev cluster..." fi - name: 'Login via oc cli & deploy' @@ -115,18 +128,30 @@ jobs: echo "dc siibra-explorer-branch-deploy-$SANITIZED_BRANCH_NAME does not yet exist, create new app..." oc new-app --template siibra-explorer-branch-deploy \ -p BRANCH_NAME=$BRANCH_NAME \ - -p SANITIZED_BRANCH_NAME=$SANITIZED_BRANCH_NAME + -p SANITIZED_BRANCH_NAME=$SANITIZED_BRANCH_NAME \ + -p PATH_POSTFIX=$PATH_POSTFIX fi - name: 'Update status badge' if: success() run: | + + if [[ "$GITHUB_REF" == 'refs/heads/master' ]] + then + DEPLOY_URL="https://siibra-explorer.apps.hbp.eu/master" + elif [[ "$GITHUB_REF" == 'refs/heads/staging' ]] + then + DEPLOY_URL="https://siibra-explorer.apps.hbp.eu/staging" + else + DEPLOY_URL="https://siibra-explorer.apps-dev.hbp.eu/${{ env.SANITIZED_BRANCH_NAME }}" + fi + curl -v \ -X POST \ -H "Authorization: Token ${{ secrets.WORKFLOW_TOKEN }}" \ -H 'accept: application/vnd.github.v3+json' \ ${GITHUB_API_ROOT}/statuses/${GITHUB_SHA} \ -d '{ - "target_url":"https://siibra-explorer.apps-dev.hbp.eu/${{ env.SANITIZED_BRANCH_NAME }}", + "target_url":"$DEPLOY_URL", "name": "Deployed at OKD", "state": "success" }' diff --git a/.openshift/okd_branch_tmpl.yaml b/.openshift/okd_branch_tmpl.yaml index 8025740e97007793ab85161c7caa901145b230c8..06e43a9e67b3740a00b47aef9eb6ef37445b4a92 100644 --- a/.openshift/okd_branch_tmpl.yaml +++ b/.openshift/okd_branch_tmpl.yaml @@ -13,7 +13,7 @@ objects: labels: app: siibra-explorer-branch-deploy-${SANITIZED_BRANCH_NAME} spec: - replicas: 1 + replicas: 3 revisionHistoryLimit: 10 selector: deploymentconfig: siibra-explorer-branch-deploy-${SANITIZED_BRANCH_NAME} @@ -116,7 +116,7 @@ objects: app: siibra-explorer-branch-deploy-${SANITIZED_BRANCH_NAME} name: siibra-explorer-branch-deploy-${SANITIZED_BRANCH_NAME} spec: - host: siibra-explorer.apps-dev.hbp.eu + host: siibra-explorer.apps${PATH_POSTFIX}.hbp.eu path: /${SANITIZED_BRANCH_NAME} port: targetPort: 8080-tcp @@ -143,6 +143,8 @@ parameters: - does not allow special characters, except for - or . . - only allows lower case. Strip all special characters from BRANCH_NAME, change to all lower case and pass it as SANITIZED_BRANCH_NAME - +- name: PATH_POSTFIX + description: url path postfix. either '-dev' or '' (empty string) + value: '' labels: template: siibra-explorer-branch-deploy-template