Skip to content

maint: add helm scripts #66

maint: add helm scripts

maint: add helm scripts #66

Workflow file for this run

name: '[docker image]'
on:
push:
branches:
- master
- staging
# do not rebuild if...
paths-ignore:
# use_docs (use_docs are built on readthedocs any way)
- 'use_docs/*'
env:
OKD_URL: https://okd.hbp.eu:443
jobs:
build-docker-img:
runs-on: ubuntu-latest
env:
DOCKERIMG: voluba
outputs:
VERSION: ${{ steps.setting-vars.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- name: 'Setup tags'
run: |
if [[ $GITHUB_REF == 'refs/heads/master' ]]; then
echo "DOCKERIMG=voluba:latest" >> "$GITHUB_ENV"
fi
if [[ $GITHUB_REF == 'refs/heads/staging' ]]; then
echo "DOCKERIMG=voluba:staging" >> "$GITHUB_ENV"
fi
- name: 'Setup tags'
run: |
if [[ -z "$DOCKERIMG" ]]
then
echo "DOCKERIMG not set!"
exit 1
fi
DOCKER_IMGSTREAM=${{ secrets.EBRAINS_DOCKER_REG_VOLUBA_NSP }}/${DOCKERIMG}
echo "Setting docker image stream to $DOCKER_IMGSTREAM"
echo "DOCKER_IMGSTREAM=$DOCKER_IMGSTREAM" >> $GITHUB_ENV
- name: 'Set matomo env var'
run: |
echo "MATOMO_URL=${{ secrets.MATOMO_URL_PROD }}" >> $GITHUB_ENV
echo "MATOMO_ID=${{ secrets.MATOMO_ID_PROD }}" >> $GITHUB_ENV
- name: 'Set version variable & expmt feature flag'
id: 'setting-vars'
run: |
GIT_HASH=$(git rev-parse --short HEAD)
echo "Setting GIT_HASH: $GIT_HASH"
echo "GIT_HASH=$GIT_HASH" >> $GITHUB_OUTPUT
VERSION=$(jq -r '.version' app/package.json)
echo "Setting VERSION: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_ENV
# VUE_APP_ENABLE_EXPERIMENTAL_FEATURES="{}"
- name: 'Build docker image'
run: |
echo "Building $DOCKER_IMGSTREAM"
docker build \
--build-arg MATOMO_URL=$MATOMO_URL \
--build-arg MATOMO_ID=$MATOMO_ID \
--build-arg VUE_APP_BACKEND_URL=${{ secrets.VUE_APP_BACKEND_URL }} \
--build-arg VUE_APP_UPLOAD_URL=${{ secrets.VUE_APP_UPLOAD_URL }} \
-t $DOCKER_IMGSTREAM \
.
echo "Successfully built $DOCKER_IMGSTREAM"
- name: 'Push to docker registry'
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_IMGSTREAM"
docker push $DOCKER_IMGSTREAM
- name: 'Tag and push version'
if: ${{ github.ref == 'refs/heads/master' }}
run: |
VERSIONED_DOCKER_IMGSTREAM=${{ secrets.EBRAINS_DOCKER_REG_VOLUBA_NSP }}/${{ env.DOCKERIMG }}:$VERSION
echo "Tagging and pushing $VERSIONED_DOCKER_IMGSTREAM"
docker tag $DOCKER_IMGSTREAM $VERSIONED_DOCKER_IMGSTREAM
docker login \
-u '${{ secrets.EBRAINS_DOCKER_REG_USER }}' \
-p '${{ secrets.EBRAINS_DOCKER_REG_TOKEN }}' \
docker-registry.ebrains.eu
docker push $VERSIONED_DOCKER_IMGSTREAM
deploy-prod-on-rancher:
needs: [ build-docker-img ]
if: ${{ github.ref == 'refs/heads/master' && success() }}
uses: ./.github/workflows/deploy-helm.yml
with:
DEPLOYMENT_NAME: voluba-prod
IMAGE_TAG: ${{ needs.build-docker-img.outputs.VERSION }}
secrets:
KUBECONFIG: ${{ secrets.KUBECONFIG }}
deploy-rc-on-rancher:
needs: [ build-docker-img ]
if: ${{ github.ref == 'refs/heads/staging' && success() }}
uses: ./.github/workflows/deploy-helm.yml
with:
DEPLOYMENT_NAME: voluba-rc
IMAGE_TAG: staging
secrets:
KUBECONFIG: ${{ secrets.KUBECONFIG }}
deploy-on-okd:
needs: [ build-docker-img ]
if: success()
runs-on: ubuntu-latest
steps:
- name: "Configure image stream"
run: |
if [[ "$GITHUB_REF" == "refs/heads/master" ]]
then
echo "IMAGE_STREAM_TAG=docker-registry.default.svc:5000/voluba/voluba-img-deploy:latest" >> $GITHUB_ENV
fi
if [[ "$GITHUB_REF" == "refs/heads/staging" ]]
then
echo "IMAGE_STREAM_TAG=docker-registry.default.svc:5000/voluba/voluba-stg-img-deploy:staging" >> $GITHUB_ENV
fi
- name: "Login via cli"
run: |
if [[ ! -z "$IMAGE_STREAM_TAG" ]]
then
oc login ${{ env.OKD_URL }} --token=${{ secrets.OKD_SECRET }}
oc project voluba
oc import-image $IMAGE_STREAM_TAG
else
echo "Empty IMAGE_STREAM_TAG, skipping"
fi