Element with modules #48
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Element with modules | |
on: | |
push: | |
branches: # we want to build the widgets from the push into Element staging and publish a main container | |
- main | |
tags: # we want to build the stable widgets into stable Element and publish the container | |
- '@nordeck/element*module*' | |
pull_request: # we want to build the widgets from the PR into Element develop & staging | |
schedule: # we want to build the stable widgets into stable Element and publish the container, plus a verification of all dev versions on a daily basis | |
- cron: '0 5 * * 1-5' | |
workflow_dispatch: # we build whatever the user inputs and publish the container | |
inputs: | |
element: | |
description: 'Element Web version (git ref, default=develop)' | |
type: 'string' | |
guestModule: | |
description: 'Element Guest module version (release tag/git ref/none, default=main)' | |
type: 'string' | |
opendeskModule: | |
description: 'Element openDesk module version (release tag/git ref/none, default=main)' | |
type: 'string' | |
lifecycleModule: | |
description: 'Element Widget Lifecycle module version (release tag/git ref/none, default=main)' | |
type: 'string' | |
togglesModule: | |
description: 'Element Widget Toggles module version (release tag/git ref/none, default=main)' | |
type: 'string' | |
jobs: | |
determine-versions: | |
name: Determine the versions for which to build containers to feed into the next job | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
permissions: | |
contents: read | |
outputs: | |
matrix: ${{ env.MATRIX }} | |
steps: | |
- name: Determine Element Web versions | |
run: | | |
VERSION_ELEMENT_DEV="develop" # Element develop branch | |
VERSION_ELEMENT_STAGING="staging" # Element branch with the latest release candidate | |
VERSION_ELEMENT_STABLE="master" # Element cut their releases from master branch | |
VERSION_ELEMENT="$VERSION_ELEMENT_DEV" | |
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/heads/main') }}; then VERSION_ELEMENT="$VERSION_ELEMENT_STAGING"; fi | |
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/tags/') }}; then VERSION_ELEMENT="$VERSION_ELEMENT_STABLE"; fi | |
if [[ "${{ inputs.element }}" != "" ]]; then VERSION_ELEMENT="${{ inputs.element }}"; fi | |
echo "VERSION_ELEMENT=$VERSION_ELEMENT" >> $GITHUB_ENV | |
echo "VERSION_ELEMENT_STAGING=$VERSION_ELEMENT_STAGING" >> $GITHUB_ENV | |
echo "VERSION_ELEMENT_STABLE=$VERSION_ELEMENT_STABLE" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
with: | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Determine Guest module versions | |
run: | | |
VERSION_MOD_GUEST_STABLE="$(git describe --match="@nordeck/element-web-guest-module*" --abbrev=0)" | |
VERSION_MOD_GUEST="main" # Development version | |
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/tags/') }}; then VERSION_MOD_GUEST="$VERSION_MOD_GUEST_STABLE"; fi # latest release | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then VERSION_MOD_GUEST=${{ github.sha }}; fi # the local PR version | |
if [[ "${{ inputs.guestModule }}" != "" ]]; then VERSION_MOD_GUEST=${{ inputs.guestModule }}; fi | |
echo "VERSION_MOD_GUEST=$VERSION_MOD_GUEST" >> $GITHUB_ENV | |
echo "VERSION_MOD_GUEST_STABLE=$VERSION_MOD_GUEST_STABLE" >> $GITHUB_ENV | |
- name: Determine openDesk module versions | |
run: | | |
VERSION_MOD_OPENDESK_STABLE="$(git describe --match="@nordeck/element-web-opendesk-module*" --abbrev=0)" | |
VERSION_MOD_OPENDESK="main" # Development version | |
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/tags/') }}; then VERSION_MOD_OPENDESK="$VERSION_MOD_OPENDESK_STABLE"; fi # latest release | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then VERSION_MOD_OPENDESK=${{ github.sha }}; fi # the local PR version | |
if [[ "${{ inputs.opendeskModule }}" != "" ]]; then VERSION_MOD_OPENDESK=${{ inputs.opendeskModule }}; fi | |
echo "VERSION_MOD_OPENDESK=$VERSION_MOD_OPENDESK" >> $GITHUB_ENV | |
echo "VERSION_MOD_OPENDESK_STABLE=$VERSION_MOD_OPENDESK_STABLE" >> $GITHUB_ENV | |
- name: Determine Widget Lifecycle module versions | |
run: | | |
VERSION_MOD_LIFECYCLE_STABLE="$(git describe --match="@nordeck/element-web-widget-lifecycle-module*" --abbrev=0)" # latest release | |
VERSION_MOD_LIFECYCLE="main" # Development version | |
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/tags/') }}; then VERSION_MOD_LIFECYCLE="$VERSION_MOD_LIFECYCLE_STABLE"; fi # latest release | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then VERSION_MOD_LIFECYCLE=${{ github.sha }}; fi # the local PR version | |
if [[ "${{ inputs.lifecycleModule }}" != "" ]]; then VERSION_MOD_LIFECYCLE=${{ inputs.lifecycleModule }}; fi | |
echo "VERSION_MOD_LIFECYCLE=$VERSION_MOD_LIFECYCLE" >> $GITHUB_ENV | |
echo "VERSION_MOD_LIFECYCLE_STABLE=$VERSION_MOD_LIFECYCLE_STABLE" >> $GITHUB_ENV | |
- name: Determine Widget Toggles module versions | |
run: | | |
VERSION_MOD_TOGGLES_STABLE="$(git describe --match="@nordeck/element-web-widget-toggles-module*" --abbrev=0)" | |
VERSION_MOD_TOGGLES="main" # Development version | |
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/tags/') }}; then VERSION_MOD_TOGGLES="$VERSION_MOD_TOGGLES_STABLE"; fi | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then VERSION_MOD_TOGGLES=${{ github.sha }}; fi # the local PR version | |
if [[ "${{ inputs.togglesModule }}" != "" ]]; then VERSION_MOD_TOGGLES=${{ inputs.togglesModule }}; fi | |
echo "VERSION_MOD_TOGGLES=$VERSION_MOD_TOGGLES" >> $GITHUB_ENV | |
echo "VERSION_MOD_TOGGLES_STABLE=$VERSION_MOD_TOGGLES_STABLE" >> $GITHUB_ENV | |
- name: Create job matrix from version combinations to build | |
# Create a JSON array of maps, each map being a combination of element + module versions. | |
# The next step will consume this as an input to a "matrix" configuration. | |
# We use only the "include" list for the matrix to define (a number of) sets of specific versions. | |
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow#expanding-or-adding-matrix-configurations | |
run: | | |
LOCAL="{\"element\": \"${{ env.VERSION_ELEMENT }}\", \"guest\": \"${{ env.VERSION_MOD_GUEST }}\", \"opendesk\": \"${{ env.VERSION_MOD_OPENDESK }}\", \"lifecycle\": \"${{ env.VERSION_MOD_LIFECYCLE }}\", \"toggles\": \"${{ env.VERSION_MOD_TOGGLES }}\"}" | |
echo $LOCAL | jq | |
SECONDARY="" | |
if [[ "${{ github.event_name }}" == "pull_request" ]] | |
then | |
SECONDARY="{\"element\": \"${{ env.VERSION_ELEMENT_STAGING }}\", \"guest\": \"${{ env.VERSION_MOD_GUEST }}\", \"opendesk\": \"${{ env.VERSION_MOD_OPENDESK }}\", \"lifecycle\": \"${{ env.VERSION_MOD_LIFECYCLE }}\", \"toggles\": \"${{ env.VERSION_MOD_TOGGLES }}\"}" | |
echo $SECONDARY | jq | |
SECONDARY=",$SECONDARY" | |
elif [[ "${{ github.event_name }}" == "schedule" ]] | |
then | |
SECONDARY="{\"element\": \"${{ env.VERSION_ELEMENT_STABLE }}\", \"guest\": \"${{ env.VERSION_MOD_GUEST_STABLE }}\", \"opendesk\": \"${{ env.VERSION_MOD_OPENDESK_STABLE }}\", \"lifecycle\": \"${{ env.VERSION_MOD_LIFECYCLE_STABLE }}\", \"toggles\": \"${{ env.VERSION_MOD_TOGGLES_STABLE }}\"}" | |
echo $SECONDARY | jq | |
SECONDARY=",$SECONDARY" | |
fi | |
MATRIX="[${LOCAL}${SECONDARY}]" | |
echo $MATRIX | jq | |
echo "MATRIX=$MATRIX" >> $GITHUB_ENV | |
build-container: | |
name: Build OCI container of Element with modules | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
permissions: | |
contents: read | |
packages: write | |
needs: determine-versions | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{ fromJson(needs.determine-versions.outputs.matrix) }} | |
env: | |
DOCKER_PLATFORMS: linux/amd64,linux/arm64 | |
steps: | |
- name: Announce versions | |
run: | | |
echo "Building Element Web with modules, versions:" | |
echo "- Dockerfile ${{ github.sha }}" | |
echo "- Element Web ${{ matrix.element }}" | |
echo "- Guest module ${{ matrix.guest }}" | |
echo "- openDesk module ${{ matrix.opendesk }}" | |
echo "- Widget Lifecycle module ${{ matrix.lifecycle }}" | |
echo "- Widget Toggles module ${{ matrix.toggles }}" | |
- uses: actions/checkout@v4 | |
- name: Set up node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Set up build_config.yaml | |
run: | | |
echo "modules:" > ../build_config.yaml | |
- name: Checkout Guest module version | |
if: ${{ matrix.guest != 'none' }} | |
uses: actions/checkout@v4 | |
with: | |
ref: '${{ matrix.guest }}' | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Build Guest module | |
if: ${{ ! (startsWith(matrix.guest, '@nordeck') || startsWith(matrix.guest, 'none')) }} | |
run: | | |
yarn install --frozen-lockfile | |
yarn workspace @nordeck/element-web-guest-module package | |
mv packages/element-web-guest-module/nordeck-element-web-guest-module.tgz ../ | |
- name: Generate Guest module build_config.yaml entry and customisations.json | |
if: ${{ matrix.guest != 'none' }} | |
env: | |
VERSION: ${{ matrix.guest }} | |
IS_REF: ${{ ! startsWith(matrix.guest, '@nordeck') }} | |
run: | | |
VERSION="${{ env.VERSION }}" | |
HUMAN_GUEST="v$(echo ${{ env.VERSION }} | tr "@" "\n" | tail -1)" | |
if ${{ env.IS_REF }} | |
then | |
VERSION="file:nordeck-element-web-guest-module.tgz" | |
HUMAN_GUEST="$(git describe --exclude='*' --always)" | |
fi | |
echo " - '$VERSION'" >> ../build_config.yaml | |
cp e2e/src/deploy/elementWeb/customisations.json ../ | |
HUMAN_GUEST="+g-${HUMAN_GUEST}" | |
echo "HUMAN_GUEST=$HUMAN_GUEST" >> $GITHUB_ENV | |
- name: Checkout openDesk module version | |
if: ${{ matrix.opendesk != 'none' }} | |
uses: actions/checkout@v4 | |
with: | |
ref: '${{ matrix.opendesk }}' | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Build openDesk module | |
if: ${{ ! (startsWith(matrix.opendesk, '@nordeck') || startsWith(matrix.opendesk, 'none')) }} | |
run: | | |
yarn install --frozen-lockfile | |
yarn workspace @nordeck/element-web-opendesk-module package | |
mv packages/element-web-opendesk-module/nordeck-element-web-opendesk-module.tgz ../ | |
- name: Generate openDesk module build_config.yaml entry | |
if: ${{ matrix.opendesk != 'none' }} | |
env: | |
VERSION: ${{ matrix.opendesk }} | |
IS_REF: ${{ ! startsWith(matrix.opendesk, '@nordeck') }} | |
run: | | |
VERSION="${{ env.VERSION }}" | |
HUMAN_OPENDESK="v$(echo ${{ env.VERSION }} | tr "@" "\n" | tail -1)" | |
if ${{ env.IS_REF }} | |
then | |
VERSION="file:nordeck-element-web-opendesk-module.tgz" | |
HUMAN_OPENDESK="$(git describe --exclude='*' --always)" | |
fi | |
echo " - '$VERSION'" >> ../build_config.yaml | |
HUMAN_OPENDESK="+od-${HUMAN_OPENDESK}" | |
echo "HUMAN_OPENDESK=$HUMAN_OPENDESK" >> $GITHUB_ENV | |
- name: Checkout Widget Lifecycle module version | |
if: ${{ matrix.lifecycle != 'none' }} | |
uses: actions/checkout@v4 | |
with: | |
ref: '${{ matrix.lifecycle }}' | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Build Widget Lifecycle module | |
if: ${{ ! (startsWith(matrix.lifecycle, '@nordeck') || startsWith(matrix.lifecycle, 'none')) }} | |
run: | | |
yarn install --frozen-lockfile | |
yarn workspace @nordeck/element-web-widget-lifecycle-module package | |
mv packages/element-web-widget-lifecycle-module/nordeck-element-web-widget-lifecycle-module.tgz ../ | |
- name: Generate Widget Lifecycle module build_config.yaml entry | |
if: ${{ matrix.lifecycle != 'none' }} | |
env: | |
VERSION: ${{ matrix.lifecycle }} | |
IS_REF: ${{ ! startsWith(matrix.lifecycle, '@nordeck') }} | |
run: | | |
VERSION="${{ env.VERSION }}" | |
HUMAN_LIFECYCLE="v$(echo ${{ env.VERSION }} | tr "@" "\n" | tail -1)" | |
if ${{ env.IS_REF }} | |
then | |
VERSION="file:nordeck-element-web-widget-lifecycle-module.tgz" | |
HUMAN_LIFECYCLE="$(git describe --exclude='*' --always)" | |
fi | |
echo " - '$VERSION'" >> ../build_config.yaml | |
HUMAN_LIFECYCLE="+wl-${HUMAN_LIFECYCLE}" | |
echo "HUMAN_LIFECYCLE=$HUMAN_LIFECYCLE" >> $GITHUB_ENV | |
- name: Checkout Widget Toggles module version | |
if: ${{ matrix.toggles != 'none' }} | |
uses: actions/checkout@v4 | |
with: | |
ref: '${{ matrix.toggles }}' | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Build Widget Toggles module | |
if: ${{ ! (startsWith(matrix.toggles, '@nordeck') || startsWith(matrix.toggles, 'none')) }} | |
run: | | |
yarn install --frozen-lockfile | |
yarn workspace @nordeck/element-web-widget-toggles-module package | |
mv packages/element-web-widget-toggles-module/nordeck-element-web-widget-toggles-module.tgz ../ | |
- name: Generate Widget Toggles module build_config.yaml entry | |
if: ${{ matrix.toggles != 'none' }} | |
env: | |
VERSION: ${{ matrix.toggles }} | |
IS_REF: ${{ ! startsWith(matrix.toggles, '@nordeck') }} | |
run: | | |
VERSION=${{ env.VERSION }} | |
HUMAN_TOGGLES="v$(echo ${{ env.VERSION }} | tr "@" "\n" | tail -1)" | |
if ${{ env.IS_REF }} | |
then | |
VERSION="file:nordeck-element-web-widget-toggles-module.tgz" | |
HUMAN_TOGGLES="$(git describe --exclude='*' --always)" | |
fi | |
echo " - '$VERSION'" >> ../build_config.yaml | |
HUMAN_TOGGLES="+wt-${HUMAN_TOGGLES}" | |
echo "HUMAN_TOGGLES=$HUMAN_TOGGLES" >> $GITHUB_ENV | |
- name: Checkout Dockerfile version | |
uses: actions/checkout@v4 | |
- name: Checkout Element version | |
uses: actions/checkout@v4 | |
with: | |
repository: element-hq/element-web | |
ref: ${{ matrix.element }} | |
path: element-web | |
fetch-tags: true | |
- name: Determine human readable Element Web version | |
env: | |
IS_RELEASE: ${{ matrix.element == 'staging' || matrix.element == 'master' || startsWith(matrix.element,'v') }} | |
working-directory: element-web | |
run: | | |
HUMAN_ELEMENT="$(git describe --exclude='*' --always)" | |
if ${{ env.IS_RELEASE }}; then HUMAN_ELEMENT="$(git describe --abbrev=0)"; fi | |
echo "HUMAN_ELEMENT=$HUMAN_ELEMENT" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/nordeck/element-web-modules | |
labels: | | |
org.opencontainers.image.title=Element Web with modules | |
org.opencontainers.image.description=A ready to use Element Web with all Nordeck modules. | |
org.opencontainers.image.vendor=Nordeck IT + Consulting GmbH | |
tags: | | |
type=raw,value=ew-${{ env.HUMAN_ELEMENT }}${{ env.HUMAN_GUEST }}${{ env.HUMAN_OPENDESK }}${{ env.HUMAN_LIFECYCLE }}${{ env.HUMAN_TOGGLES }} | |
# It can't start with a period or hyphen and must be no longer than 128 characters. | |
- name: Collect module source files | |
run: | | |
mv ../build_config.yaml e2e/src/deploy/elementWeb/ | |
mv ../customisations.json e2e/src/deploy/elementWeb/ || ${{ matrix.guest == 'none' }} | |
mv ../nordeck-element-web-guest-module.tgz e2e/src/deploy/elementWeb/ || ${{ startsWith(matrix.guest, '@nordeck') || startsWith(matrix.guest, 'none') }} | |
mv ../nordeck-element-web-opendesk-module.tgz e2e/src/deploy/elementWeb/ || ${{ startsWith(matrix.opendesk, '@nordeck') || startsWith(matrix.opendesk, 'none') }} | |
mv ../nordeck-element-web-widget-lifecycle-module.tgz e2e/src/deploy/elementWeb/ || ${{ startsWith(matrix.lifecycle, '@nordeck') || startsWith(matrix.lifecycle, 'none') }} | |
mv ../nordeck-element-web-widget-toggles-module.tgz e2e/src/deploy/elementWeb/ || ${{ startsWith(matrix.toggles, '@nordeck') || startsWith(matrix.toggles, 'none') }} | |
- name: Build | |
uses: docker/build-push-action@v6 | |
with: | |
context: e2e/src/deploy/elementWeb/ | |
build-args: | | |
ELEMENT_VERSION=${{ matrix.element }} | |
platforms: ${{ env.DOCKER_PLATFORMS }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) || github.event_name == 'schedule' && matrix.element == 'master' || github.event_name == 'workflow_dispatch' }} |