Skip to content

package-backend-variant #641

package-backend-variant

package-backend-variant #641

name: package-backend-variant
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
on:
workflow_dispatch:
inputs:
variantName:
description: 'Variant Name'
required: true
default: 'internal'
baseVersion:
description: 'Version of Base Image and Repository Tag; example: 0.14.80'
required: true
pluginsBackend:
description: "Backend-Plugin spec; example: OKPluginGenericJSONIngest:0.14.80;OKPluginActiveDirectoryXMLIngest:0.14.80;"
required: true
runSystemTests:
description: "Whether or not to run system tests after a successful image build/publish; \"true\" or \"false\""
required: true
jobs:
build-publish-variant-backend:
runs-on: ubuntu-20.04
env:
VARIANT_NAME: ${{ github.event.inputs.variantName }}
BASE_VERSION: ${{ github.event.inputs.baseVersion }}
PLUGINS_BACKEND: ${{ github.event.inputs.pluginsBackend }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: ${{ env.BASE_VERSION }}
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set final backend version
run: |
# create plugin hash from plugins string
PLUGIN_HASH=`echo $PLUGINS_BACKEND | md5sum | cut -f1 -d" " | cut -c1-10`
# NOTE: according to semver, we should use a '+', followed by the plugin hash to specify the "build-metadata"
# but docker image tags do not allow '+', so we use a '-' instead
echo "FINAL_VERSION_BACKEND=${BASE_VERSION}-${PLUGIN_HASH}" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for docker backend
id: meta_backend
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/variants/backend/${{ env.VARIANT_NAME }}
tags: |
type=raw,value=${{ env.FINAL_VERSION_BACKEND }}
flavor: |
latest=true
- name: Setup backend build
run: |
mkdir -p build-backend
cp backend/Omnikeeper/Dockerfile_AddedOKPlugins build-backend/Dockerfile
- name: Download backend plugins
run: |
echo "Fetching plugins..."
mkdir -p build-backend/OKPlugins
plugins=$(echo $PLUGINS_BACKEND | tr ";" "\n")
for plugin in $plugins
do
pluginArray=(`echo $plugin | tr ":" "\n"`)
pluginName=${pluginArray[0]}
pluginVersion=${pluginArray[1]}
echo "Fetching plugin '$pluginName' version $pluginVersion"
curl --fail -L -u ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} https://nuget.pkg.github.com/max-bytes/download/$pluginName/$pluginVersion/$pluginName.$pluginVersion.nupkg --output build-backend/OKPlugins/$pluginName-$pluginVersion.nupkg
done
echo "Done fetching plugins"
- name: Build and push backend Docker image
uses: docker/build-push-action@v2
with:
context: "./build-backend"
file: "./build-backend/Dockerfile"
push: true
build-args: |
base_image=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/core/backend:${{ env.BASE_VERSION }}
tags: ${{ steps.meta_backend.outputs.tags }}
labels: ${{ steps.meta_backend.outputs.labels }}
- name: "Invoke system tests"
uses: benc-uk/workflow-dispatch@v1
if: github.event.inputs.runSystemTests == 'true'
with:
workflow: run-system-tests
token: ${{ secrets.PAT }}