Skip to content
This repository was archived by the owner on Dec 29, 2025. It is now read-only.

Commit 2a16744

Browse files
committed
feat(integration): add example how to decode buildingBlockRun inputs in GitHub action job step using jq
1 parent 04de6b7 commit 2a16744

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

docs/integrations/github/github-actions.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,40 @@ on:
145145
required: true
146146
```
147147
148-
This setup allows application teams to quickly and efficiently access automation workflows from the marketplace, enhancing their productivity and reducing the need for Git expertise.
148+
Within a job, you need to decode the `buildingBlockRun` input.
149+
Define a job step to decode all Building Block inputs as follows and provide them to following steps:
150+
```yaml
151+
jobs:
152+
some-job:
153+
runs-on: ubuntu-latest # ships with jq already!
154+
steps:
155+
# ... some other steps
156+
- name: Decode buildingBlockRun inputs
157+
id: decodeBuildingBlockInputs
158+
shell: bash
159+
env:
160+
# pass in indirectly as env variable to avoid cluttering the job log with a large base64 string
161+
BUILDING_BLOCK_RUN_INPUT: ${{ inputs.buildingBlockRun }}
162+
run: |
163+
set -euo pipefail
164+
base64 -d <<<"$BUILDING_BLOCK_RUN_INPUT" \
165+
| jq -er '
166+
.spec.buildingBlock.spec.inputs
167+
| unique_by(.key)
168+
| .[]
169+
| "\(.key)=\(.value)"
170+
' \
171+
| tee -a "$GITHUB_OUTPUT" # assumes no secrets are passed in as inputs, as they're printed by tee!
172+
# ... do something with the output (example):
173+
- name: Some step using an input
174+
run: |
175+
# Assumes the building block definition has an input called 'github_handle'
176+
echo '${{ steps.decodeBuildingBlockInputs.outputs.github_handle }}'
177+
```
178+
<!-- Above step "Decode buildingBlockRun inputs" is actually used here:
179+
https://github.com/meshcloud/github-copilot-licenses/blob/79450d14d70d149d8a207edbc9df51078cb113e2/.github/actions/setup/action.yml#L40-L49
180+
-->
181+
<!-- TODO: Once https://github.com/meshcloud/meshfed-release/pull/9016 is merged/release, the unique_by(.key) workaround can be removed -->
149182

150183
### Status Updates
151184

0 commit comments

Comments
 (0)