Newer
Older
on:
push:
# do not rebuild if...
paths-ignore:
# changes to .openshift directory... mostly devops config
- '.openshift/*'
# docs (docs are built on readthedocs any way)
jobs:
build-docker-img:
runs-on: ubuntu-latest
env:
MATOMO_ID_PROD: '12'
SIIBRA_API_STABLE: 'https://siibra-api-stable.apps.hbp.eu/v3_0,https://siibra-api-stable.apps.jsc.hbp.eu/v3_0'
SIIBRA_API_LATEST: 'https://siibra-api-latest.apps-dev.hbp.eu/v3_0'
SIIBRA_API_LOCAL: 'http://localhost:10081/v3_0'
LOCAL_TAG: 'local-10081'
strategy:
matrix:
build: [ 'local', 'prod' ]
- name: 'Set matomo env var'
# if matrix.build is local, only run if master or dev
if: ${{ !(matrix.build == 'local' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/dev') }}
run: |
echo "Using github.ref: $GITHUB_REF"
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "MATOMO_URL=${{ env.MATOMO_URL_PROD }}" >> $GITHUB_ENV
echo "MATOMO_ID=${{ env.MATOMO_ID_PROD }}" >> $GITHUB_ENV
echo "SIIBRA_API_ENDPOINTS=${{ env.SIIBRA_API_STABLE }}" >> $GITHUB_ENV
elif [[ "$GITHUB_REF" == 'refs/heads/staging' ]]
then
echo "Either staging, using staging env..."
echo "SIIBRA_API_ENDPOINTS=${{ env.SIIBRA_API_RC }}" >> $GITHUB_ENV
if [[ "$GITHUB_REF" == *hotfix* ]]
then
echo "Hotfix branch, using prod env..."
echo "SIIBRA_API_ENDPOINTS=${{ env.SIIBRA_API_RC }}" >> $GITHUB_ENV
else
echo "Using dev env..."
echo "SIIBRA_API_ENDPOINTS=${{ env.SIIBRA_API_LATEST }}" >> $GITHUB_ENV
if [[ "${{ matrix.build }}" == "local" ]]
then
echo "SIIBRA_API_ENDPOINTS=${{ env.SIIBRA_API_LOCAL }}" >> $GITHUB_ENV
echo "MATOMO_URL=" >> $GITHUB_ENV
echo "MATOMO_ID=" >> $GITHUB_ENV
- name: 'Set version variable & expmt feature flag'
# if matrix.build is local, only run if master or dev
if: ${{ !(matrix.build == 'local' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/dev') }}
run: |
if [[ "$GITHUB_REF" == 'refs/heads/master' ]] || [[ "$GITHUB_REF" == 'refs/heads/staging' ]]
then
echo "EXPERIMENTAL_FEATURE_FLAG=true" >> $GITHUB_ENV
fi
- name: 'Build docker image'
# if matrix.build is local, only run if master or dev
if: ${{ !(matrix.build == 'local' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/dev') }}
run: |
DOCKER_BUILT_TAG=${{ env.DOCKER_REGISTRY }}siibra-explorer:$BRANCH_NAME
if [[ "${{ matrix.build }}" == "local" ]]
then
DOCKER_BUILT_TAG="$DOCKER_BUILT_TAG"-${{ env.LOCAL_TAG }}
fi
echo "Building $DOCKER_BUILT_TAG"
docker build \
--build-arg MATOMO_URL=$MATOMO_URL \
--build-arg MATOMO_ID=$MATOMO_ID \
--build-arg SIIBRA_API_ENDPOINTS=$SIIBRA_API_ENDPOINTS \
--build-arg EXPERIMENTAL_FEATURE_FLAG=$EXPERIMENTAL_FEATURE_FLAG \
-t $DOCKER_BUILT_TAG \
.
echo "Successfully built $DOCKER_BUILT_TAG"
echo "DOCKER_BUILT_TAG=$DOCKER_BUILT_TAG" >> $GITHUB_ENV
- name: 'Push to docker registry'
# if matrix.build is local, only run if master or dev
if: ${{ !(matrix.build == 'local' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/dev') }}
run: |
echo "Login to docker registry"
docker login \
-u '${{ secrets.EBRAINS_DOCKER_REG_USER }}' \
-p '${{ secrets.EBRAINS_DOCKER_REG_TOKEN }}' \
docker-registry.ebrains.eu
echo "Pushing $DOCKER_BUILT_TAG"
docker push $DOCKER_BUILT_TAG
outputs:
BRANCH_NAME: ${{ steps.set-vars.outputs.BRANCH_NAME }}
BUILD_TEXT: ${{ steps.set-vars.outputs.BUILD_TEXT }}
DEPLOY_ID: ${{ steps.set-vars.outputs.DEPLOY_ID }}
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT
echo "BUILD_TEXT=$BRANCH_NAME" >> $GITHUB_OUTPUT
# DEPLOY_ID == remove _ / and lowercase everything from branch
DEPLOY_ID=$(echo ${BRANCH_NAME//[_\/]/} | awk '{ print tolower($0) }')
echo "DEPLOY_ID=$DEPLOY_ID" >> $GITHUB_OUTPUT
trigger-deploy-master-prod:
if: ${{ needs.setting-vars.outputs.BRANCH_NAME == 'master' && success() }}
needs:
- build-docker-img
- setting-vars
uses: ./.github/workflows/deploy-on-okd.yml
with:
FULL_DEPLOY_ID: siibra-explorer-branch-deploy-2-prodpathviewer
OKD_ENDPOINT: https://okd.hbp.eu:443
OKD_PROJECT: interactive-viewer
secrets:
okd_token: ${{ secrets.OKD_PROD_SECRET }}
trigger-deploy-master-rancher:
if: ${{ needs.setting-vars.outputs.BRANCH_NAME == 'master' && success() }}
needs:
- build-docker-img
- setting-vars
uses: ./.github/workflows/deploy-helm.yml
with:
IMAGE_TAG: master
secrets:
KUBECONFIG: ${{ secrets.KUBECONFIG }}
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
trigger-deploy-master-legacy:
if: ${{ needs.setting-vars.outputs.BRANCH_NAME == 'master' && success() }}
needs:
- build-docker-img
- setting-vars
uses: ./.github/workflows/deploy-on-okd.yml
with:
FULL_DEPLOY_ID: siibra-explorer-branch-deploy-2-iav-legacy
OKD_ENDPOINT: https://okd.hbp.eu:443
OKD_PROJECT: interactive-viewer
secrets:
okd_token: ${{ secrets.OKD_PROD_SECRET }}
trigger-deploy-staging-viewer-validation:
if: ${{ needs.setting-vars.outputs.BRANCH_NAME == 'staging' && success() }}
needs:
- build-docker-img
- setting-vars
uses: ./.github/workflows/deploy-on-okd.yml
with:
FULL_DEPLOY_ID: siibra-explorer-branch-deploy-2-stagingpathed
OKD_ENDPOINT: https://okd.hbp.eu:443
OKD_PROJECT: interactive-viewer
secrets:
okd_token: ${{ secrets.OKD_PROD_SECRET }}
trigger-deploy-staging-data-validation:
if: ${{ needs.setting-vars.outputs.BRANCH_NAME == 'staging' && success() }}
needs:
- build-docker-img
- setting-vars
uses: ./.github/workflows/deploy-on-okd.yml
with:
FULL_DEPLOY_ID: siibra-explorer-rc
OKD_ENDPOINT: https://okd.jsc.hbp.eu:443
OKD_PROJECT: siibra-explorer
secrets:
okd_token: ${{ secrets.OKD_JSC_TOKEN }}
trigger-deploy-other-viewer:
# n.b. "env" context not available in "if" block
if: ${{ needs.setting-vars.outputs.BRANCH_NAME != 'staging' && needs.setting-vars.outputs.BRANCH_NAME != 'master' && success() }}
uses: ./.github/workflows/deploy-on-okd.yml
needs:
- build-docker-img
- setting-vars
with:
FULL_DEPLOY_ID: siibra-explorer-branch-deploy-2-${{ needs.setting-vars.outputs.DEPLOY_ID }}
OKD_ENDPOINT: https://okd-dev.hbp.eu:443
OKD_PROJECT: interactive-atlas-viewer
BRANCH_NAME: ${{ needs.setting-vars.outputs.BRANCH_NAME }}
DEPLOY_ID: ${{ needs.setting-vars.outputs.DEPLOY_ID }}
ROUTE_HOST: siibra-explorer.apps-dev.hbp.eu
ROUTE_PATH: /${{ needs.setting-vars.outputs.DEPLOY_ID }}
BUILD_TEXT: ${{ needs.setting-vars.outputs.BRANCH_NAME }}
secrets:
okd_token: ${{ secrets.OKD_DEV_SECRET }}
trigger-deploy-other-badge:
if: ${{ needs.setting-vars.outputs.BRANCH_NAME != 'staging' && needs.setting-vars.outputs.BRANCH_NAME != 'master' && success() }}
runs-on: ubuntu-latest
env:
DEPLOY_URL: https://siibra-explorer.apps-dev.hbp.eu/${{ needs.setting-vars.outputs.DEPLOY_ID }}
GITHUB_API_ROOT: https://api.github.com/repos/fzj-inm1-bda/siibra-explorer
needs:
- trigger-deploy-other-viewer
- setting-vars
steps:
- name: "Update Badge"
run: |
curl -v \
-X POST \
-H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H 'accept: application/vnd.github.v3+json' \
${GITHUB_API_ROOT}/statuses/${GITHUB_SHA} \
-d '{