Skip to content

bmd-atem updated to v3.14.1 by Julusian #1753

bmd-atem updated to v3.14.1 by Julusian

bmd-atem updated to v3.14.1 by Julusian #1753

Workflow file for this run

name: Update Module
run-name: ${{ github.event.inputs.module-name }} updated to ${{ github.event.inputs.git-ref }} by ${{ github.actor }}
# Controls when the workflow will run
on:
workflow_dispatch:
inputs:
module-name:
type: string
description: Name of the module (eg bmd-atem)
required: true
git-ref:
type: string
description: Git ref to build (tag/commit)
required: true
jobs:
build:
runs-on: ubuntu-latest
# The first stage is to build their module
# Remember that this is running user code, so we need to make sure not to leak any secrets
permissions:
packages: read
steps:
- name: Report info
run: |
echo "Updating **${{ github.event.inputs.module-name }}** to ${{ github.event.inputs.git-ref }} :rocket:" >> $GITHUB_STEP_SUMMARY
- name: Clone module
run: |
git clone https://github.com/bitfocus/companion-module-${{ github.event.inputs.module-name }} -b "${{ github.event.inputs.git-ref }}" "${{ github.event.inputs.module-name }}"
- name: Determine nodejs version
id: determine-nodejs
run: |
NODE_VERSION=$(jq '.runtime.type' ${{ github.event.inputs.module-name }}/companion/manifest.json)
echo "Node.js version: $NODE_VERSION"
if [ "$NODE_VERSION" == "\"node18\"" ]; then
echo "Using Node.js 18.x"
echo "version=18.x" >> $GITHUB_OUTPUT
elif [ "$NODE_VERSION" == "\"node22\"" ]; then
echo "Using Node.js 22.x"
echo "version=22.x" >> $GITHUB_OUTPUT
fi
- name: Use Node.js ${{ steps.determine-nodejs.outputs.version }}
uses: actions/setup-node@v4
with:
node-version: ${{ steps.determine-nodejs.outputs.version }}
- name: Enable corepack
run: |
corepack enable
- name: Collect info
run: |
cd ${{ github.event.inputs.module-name }}
MANIFEST_ID=$(jq '.["id"]' companion/manifest.json)
if [ ! "$MANIFEST_ID" == "\"${{ github.event.inputs.module-name }}\"" ]; then
echo "Module manifest.json id does not match github repository name"
exit 99
fi
if grep -q "companion-module-your-module-name" "companion/manifest.json"; then
echo "Module manifest contains references to companion-module-your-module-name!"
exit 99
fi
if ! jq -e '.products | arrays and length > 0' companion/manifest.json > /dev/null; then
echo "Module manifest product list is either empty or does not exist"
exit 99
fi
GIT_HASH=$(git rev-parse HEAD)
echo "git-hash=$GIT_HASH" >> $GITHUB_OUTPUT
- name: Setup Github packages auth
run: |
# TODO: support yarn3 with something like (needs a syntax check)
# yarn config set npmRegistries.//npm.pkg.github.com.npmAuthToken $NPM_AUTH_TOKEN
echo "//npm.pkg.github.com/:_authToken=${{ github.token }}" >> ~/.npmrc
- name: Prepare module
run: |
cd ${{ github.event.inputs.module-name }}
yarn install
# yarn build would be better, but lacks the --if-present property
npm run build --if-present
- name: Package module
run: |
cd ${{ github.event.inputs.module-name }}
yarn companion-module-build
- uses: actions/upload-artifact@v4
with:
name: pkg
path: ${{ github.event.inputs.module-name }}/pkg.tgz
retention-days: 1
commit:
runs-on: ubuntu-latest
needs: build
# The second stage is to commit the module to the repository
# only allow one workflow to run this step at a time
concurrency: add-module-${{ github.ref }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
path: modules
ref: ${{ github.ref_name }}
- uses: actions/download-artifact@v4
with:
name: pkg
- name: Package module
run: |
tar -xvzf pkg.tgz
UPDATE_DATE=$(date +%Y-%m-%d)
# cleanup some junk
rm -Rf pkg/.yarn || true
tee -a pkg/.build-info <<EOF
MODULE_NAME=${{ github.event.inputs.module-name }}
GIT_REF=${{ github.event.inputs.git-ref }}
RUN_URL=https://github.com/bitfocus/companion-bundled-modules/actions/runs/${{ github.run_id }}
UPDATE_DATE=$UPDATE_DATE
EOF
# TODO - verify module looks valid?
# make sure there isn't a legacy version
rm -Rf modules/_legacy/companion-module-${{ github.event.inputs.module-name }} || true
rm -Rf modules/${{ github.event.inputs.module-name }} || true
mv pkg modules/${{ github.event.inputs.module-name }}
- name: Commit updated module
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: modules
commit_message: "update ${{ github.event.inputs.module-name }} to ${{ github.event.inputs.git-ref }}"