Skip to content

5o65NpwMABE-ycQGSodFZ: generic-emberplus updated to v2.6.2(ce9086538b578efbefd5fdee13811a74e4bb2812) #97

5o65NpwMABE-ycQGSodFZ: generic-emberplus updated to v2.6.2(ce9086538b578efbefd5fdee13811a74e4bb2812)

5o65NpwMABE-ycQGSodFZ: generic-emberplus updated to v2.6.2(ce9086538b578efbefd5fdee13811a74e4bb2812) #97

name: Portal Update Module
run-name: "${{ github.event.inputs.run-id }}: ${{ github.event.inputs.module-name }} updated to ${{ github.event.inputs.git-ref }}(${{ github.event.inputs.git-sha }})"
# Controls when the workflow will run
on:
workflow_dispatch:
inputs:
run-id:
type: string
description: Unique identifer for this workflow run
required: true
module-name:
type: string
description: Name of the module (eg bmd-atem)
required: true
git-ref:
type: string
description: Git ref to build
required: true
git-sha:
type: string
description: Git sha to build
required: true
jobs:
build:
name: Build module
# 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
uses: bitfocus/actions/.github/workflows/module-checks.yaml@main
with:
repository-name: bitfocus/companion-module-${{ github.event.inputs.module-name }}
git-ref: ${{ github.event.inputs.git-ref }}
git-sha-check: ${{ github.event.inputs.git-sha }}
upload-artifact: true
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:
- name: Report info
run: |
echo "Updating **${{ github.event.inputs.repository-name }}** to ${{ github.event.inputs.git-ref }}(${{ github.event.inputs.git-sha }}) :rocket:" >> $GITHUB_STEP_SUMMARY
- 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 }}"
publish:
runs-on: ubuntu-latest
needs: build
# This final stage is to publish the module to the api
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: pkg
- name: Download minio client
shell: bash
run: |
wget -q https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
- name: Upload
id: upload
shell: bash
run: |
# extract the package
tar -xvzf pkg.tgz
ARTIFACT_DIR="${{ github.event.inputs.module-name }}-${{ github.event.inputs.git-ref }}-${{ github.event.inputs.git-sha }}"
ARTIFACT_NAME="${{ github.event.inputs.module-name }}-${{ github.event.inputs.git-ref }}.tgz"
# copy the package to the companion directory
cp pkg.tgz "pkg/companion/${ARTIFACT_NAME}"
export HOME="$(pwd)" MC_CONFIG_DIR="$(pwd)"
./mc alias set remote/ https://${{ secrets.S3_HOST }} ${{ secrets.S3_KEY }} ${{ secrets.S3_SECRET }}
./mc cp "pkg/companion/" "remote/${{ secrets.S3_BUCKET }}/${ARTIFACT_DIR}" --recursive
echo "artifact-name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
echo "artifact-url=https://${{ secrets.S3_HOST }}/${{ secrets.S3_BUCKET }}/${ARTIFACT_DIR}" >> $GITHUB_OUTPUT
- name: Report to api
shell: bash
run: |
echo "Uploaded build to ${{ steps.upload.outputs.artifact-url }}" >> $GITHUB_STEP_SUMMARY
PKG_SHA256=$(sha256sum pkg.tgz | awk '{print $1}')
echo "With SHA256=${PKG_SHA256}" >> $GITHUB_STEP_SUMMARY
MANIFEST_JSON=$(cat pkg/companion/manifest.json)
MANIFEST_JSON=${MANIFEST_JSON//\"/\\\"}
# TODO: dynamic module type
# TODO: rename logUrl property
PUT_PAYLOAD='{
"moduleType": "companion-connection",
"moduleName": "${{ github.event.inputs.module-name }}",
"logUrl": "https://github.com/bitfocus/companion-bundled-modules/actions/runs/${{ github.run_id }}",
"pkgDirUrl": "${{ steps.upload.outputs.artifact-url }}",
"pkgName": "${{ steps.upload.outputs.artifact-name }}",
"pkgSha": "'${PKG_SHA256}'",
"gitTag": "${{ github.event.inputs.git-ref }}",
"gitSha": "${{ github.event.inputs.git-sha }}",
"manifestJson": "'${MANIFEST_JSON}'"
}'
echo "PUT_PAYLOAD=$PUT_PAYLOAD"
curl -X 'PUT' \
'https://developer.bitfocus.io/api/v1/modules/package' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ${{ secrets.DEVELOPER_API_KEY }}' \
-d "${PUT_PAYLOAD}"