Skip to content

v0.3.15

v0.3.15 #359

Workflow file for this run

name: '[cd]docker images'
on:
push:
branches:
- master
release:
types:
- published
env:
OKD_PROJECT: siibra-api
OKD_PROD_ENDPOINT: https://okd.hbp.eu:443
OKD_DEV_ENDPOINT: https://okd-dev.hbp.eu:443
OKD_PROD_SECRET: ${{ secrets.OKD_PROD_SECRET }}
OKD_DEV_SECRET: ${{ secrets.OKD_DEV_SECRET }}
DOCKER_REGISTRY: 'docker-registry.ebrains.eu/siibra/'
DOCKER_IMG: 'siibra-api'
jobs:
build-docker-img:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
flavor: ['server', 'worker', 'all']
include:
- flavor: 'all'
dockerfile: 'Dockerfile'
tag_suffix: ''
- flavor: 'worker'
dockerfile: 'worker.dockerfile'
tag_suffix: '-worker'
- flavor: 'server'
dockerfile: 'server.dockerfile'
tag_suffix: '-server'
steps:
- name: "Sanity check github.ref"
run: echo GITHUB_REF - $GITHUB_REF - github.ref - ${{ github.ref }}
- uses: actions/checkout@v3
- name: "Build docker image"
run: |
GIT_HASH=$(git rev-parse --short HEAD)
cached_image=${{ env.DOCKER_REGISTRY }}${{ env.DOCKER_IMG }}:latest${{ matrix.tag_suffix }}
echo "Pulling $cached_image to populate cached layers."
docker pull $cached_image
docker build --build-arg GIT_HASH=$GIT_HASH -t siibra-api-tmp-img -f ${{ matrix.dockerfile }} .
- name: "Tag and Push (latest || rc)"
if: ${{ (github.event_name == 'push') || contains(github.ref, 'rc') }}
run: |
if [[ "$GITHUB_REF" = *"rc"* ]]
then
TAG_BASE=rc
else
TAG_BASE=latest
fi
NEW_TAG=${{ env.DOCKER_REGISTRY }}${{ env.DOCKER_IMG }}:${TAG_BASE}${{ matrix.tag_suffix }}
docker tag siibra-api-tmp-img ${NEW_TAG}
echo "Login to docker registry"
docker login \
-u '${{ secrets.EBRAINS_DOCKER_REG_USER }}' \
-p '${{ secrets.EBRAINS_DOCKER_REG_TOKEN }}' \
docker-registry.ebrains.eu
docker push $NEW_TAG
- name: "Tag and Push (release)"
if : ${{ (github.event_name == 'release') && !contains(github.ref, 'rc') }}
run: |
echo "Login to docker registry"
docker login \
-u '${{ secrets.EBRAINS_DOCKER_REG_USER }}' \
-p '${{ secrets.EBRAINS_DOCKER_REG_TOKEN }}' \
docker-registry.ebrains.eu
VERSION=$(cat api/VERSION)
while [[ "$VERSION" == *"."* ]]
do
if [[ "$BREAK" == "0" ]]
then
echo "Fuse broke!"
exit 1
fi
VERSIONED_DOCKERTAG=${{ env.DOCKER_REGISTRY }}${{ env.DOCKER_IMG }}:${VERSION}${{ matrix.tag_suffix }}
echo "tagging and pushing $VERSIONED_DOCKERTAG"
docker tag siibra-api-tmp-img $VERSIONED_DOCKERTAG
docker push $VERSIONED_DOCKERTAG
echo "Push successful... Incrementing version & break"
VERSION=$(echo $VERSION | sed -e 's/\.\w*$//g')
BREAK=$(( "$BREAK" - 1 ))
done
echo "Done"
setup-envvar:
runs-on: ubuntu-latest
outputs:
queues: ${{ steps.set-env-var.outputs.queues }}
version: ${{ steps.set-env-var.outputs.version }}
needs: build-docker-img
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: 'Setting env var'
id: set-env-var
run: |
echo queues=$(python -c 'import api.siibra_api_config as cfg; print(" ".join([f"{q!r}" for q in cfg._queues]))') >> "$GITHUB_OUTPUT"
echo version=$(python -c 'import api.siibra_api_config as cfg; print(cfg.__version__)') >> "$GITHUB_OUTPUT"
deploy-latest-on-okd:
needs: setup-envvar
if: ${{ github.event_name == 'push' }}
uses: ./.github/workflows/deploy-on-okd.yml
with:
okd_endpoint: https://okd-dev.hbp.eu:443
flavor: latest
queues: ${{ needs.setup-envvar.outputs.queues }}
version: ${{ needs.setup-envvar.outputs.version }}
workerimage: docker-registry.ebrains.eu/siibra/siibra-api:latest-worker
secrets:
okd_token: ${{ secrets.OKD_DEV_SECRET }}
deploy-rc-on-okd:
needs: setup-envvar
if: ${{ github.event_name == 'release' && contains(github.ref, 'rc') }}
uses: ./.github/workflows/deploy-on-okd.yml
with:
okd_endpoint: https://okd.hbp.eu:443
flavor: rc
queues: ${{ needs.setup-envvar.outputs.queues }}
version: ${{ needs.setup-envvar.outputs.version }}
workerimage: docker-registry.ebrains.eu/siibra/siibra-api:rc-worker
secrets:
okd_token: ${{ secrets.OKD_PROD_SECRET }}
data-validation-config-hash:
if: ${{ github.event_name == 'release' && contains(github.ref, 'rc') }}
runs-on: ubuntu-latest
outputs:
CONFIG_SHORT_REV: ${{ steps.parse-rev.outputs.CONFIG_SHORT_REV }}
steps:
- id: parse-rev
name: Get short rev of HEAD at master
run: |
git clone -b v0.4EOL https://jugit.fz-juelich.de/t.dickscheid/brainscapes-configurations.git
CONFIG_SHORT_REV=$(git -C brainscapes-configurations rev-parse --short=6 HEAD)
echo CONFIG_SHORT_REV=$CONFIG_SHORT_REV >> $GITHUB_OUTPUT
deploy-rc-on-data-validation:
needs:
- setup-envvar
- data-validation-config-hash
if: ${{ github.event_name == 'release' && contains(github.ref, 'rc') }}
uses: ./.github/workflows/deploy-on-okd.yml
with:
okd_endpoint: https://okd.jsc.hbp.eu:443
flavor: rc
queues: ${{ needs.setup-envvar.outputs.queues }}
version: c.${{ needs.data-validation-config-hash.outputs.CONFIG_SHORT_REV }}
workerimage: docker-registry.ebrains.eu/siibra/siibra-api:rc-worker
secrets:
okd_token: ${{ secrets.OKD_JSC_SECRET }}
deploy-prod-on-okd:
needs: setup-envvar
if: ${{ github.event_name == 'release' && !contains(github.ref, 'rc') }}
strategy:
fail-fast: false
matrix:
deploy-site: ['jsc', 'cscs']
include:
- deploy-site: 'jsc'
okd-endpoint: https://okd.jsc.hbp.eu:443
- deploy-site: 'cscs'
okd-endpoint: https://okd.hbp.eu:443
uses: ./.github/workflows/deploy-on-okd.yml
with:
okd_endpoint: ${{ matrix.okd-endpoint }}
flavor: stable
queues: ${{ needs.setup-envvar.outputs.queues }}
version: ${{ needs.setup-envvar.outputs.version }}
workerimage: docker-registry.ebrains.eu/siibra/siibra-api:0.3-worker
secrets:
okd_token: ${{ matrix.deploy-site == 'jsc' && secrets.OKD_JSC_SECRET || secrets.OKD_PROD_SECRET }}