Skip to content

.github/workflows/publish-docker.yaml #46

.github/workflows/publish-docker.yaml

.github/workflows/publish-docker.yaml #46

on:
repository_dispatch:
types: [build-images]
workflow_dispatch:
inputs:
buildImage:
description: 'Build and push Docker Image according to the environment'
default: 'false'
commitVersionTag:
description: 'The image tag will be retrieved from the bee version command'
default: 'false'
beeVersion:
description: 'The official bee image tag that the image will be built on. Default: last supported version'
default: 'latest'
beeVersionAsCommitHash:
description:
'The beeVersion parameter will be interpreted as a source code commit hash that the bee base image will be
built on'
default: 'false'
stateCommit:
description: 'The images will have cheques by the traffic generation'
default: 'false'
latest:
description: 'The images will be tagged with latest as well'
default: 'false'
env:
BEE_IMAGE_PREFIX: 'fairdatasociety'
BUILD_IMAGE: 'false'
COMMIT_VERSION_TAG: 'false'
STATE_COMMIT: 'false'
BEE_VERSION: '${{ github.event.client_payload.tag }}'
LATEST: 'false'
jobs:
bee-images:
name: Build and publish images
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Override inputs from `workflow_dispatch`
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "BEE_VERSION=${{ github.event.inputs.beeVersion }}" >> $GITHUB_ENV
echo "BUILD_IMAGE=${{ github.event.inputs.beeVersionAsCommitHash }}" >> $GITHUB_ENV
echo "COMMIT_VERSION_TAG=${{ github.event.inputs.commitVersionTag }}" >> $GITHUB_ENV
echo "STATE_COMMIT=${{ github.event.inputs.stateCommit }}" >> $GITHUB_ENV
echo "LATEST=${{ github.event.inputs.latest }}" >> $GITHUB_ENV
else
echo "BEE_VERSION=${BEE_VERSION/v}" >> $GITHUB_ENV
fi
- name: Auth to Docker Hub
if:
${{ github.event_name == 'repository_dispatch' || (github.event.inputs.buildImage == 'true' && success()) }}
run: |
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{secrets.DOCKERHUB_USERNAME}} --password-stdin
- uses: actions/cache@v3
id: cache-npm
with:
path: orchestrator/node_modules
key: ${{ runner.os }}-${{ hashFiles('orchestrator/package-lock.json') }}
- name: Install npm deps
if: steps.cache-npm.outputs.cache-hit != 'true'
run: cd ./orchestrator && npm ci
- name: Build images
id: build
run: |
cd ./orchestrator
BUILD_PARAMS=""
if [ "$BUILD_IMAGE" = 'true' ]; then
BUILD_PARAMS+=" --build-base-bee --base-bee-commit-hash=$BEE_VERSION"
fi
if [ "$STATE_COMMIT" = 'true' ]; then
BUILD_PARAMS+=" --gen-traffic"
fi
if [ -n "$BUILD_PARAMS" ]; then
BUILD_PARAMS="-- $BUILD_PARAMS"
fi
npm run build:env $BUILD_PARAMS
- name: Release images
id: release
run: |
cd ./orchestrator
PUBLISH_PARAMS=""
if [ "$LATEST" = 'true' ]; then
PUBLISH_PARAMS+=" --latest"
fi
if [ -n "$PUBLISH_PARAMS" ]; then
PUBLISH_PARAMS="-- $PUBLISH_PARAMS"
fi
npm run publish:env $PUBLISH_PARAMS