|
| 1 | +name: "Parse release handle" |
| 2 | +description: "Parses a release_handle JSON input and extracts all available fields as outputs" |
| 3 | + |
| 4 | +inputs: |
| 5 | + release_handle: |
| 6 | + description: "JSON string containing release handle information" |
| 7 | + required: true |
| 8 | + |
| 9 | +outputs: |
| 10 | + run_id: |
| 11 | + description: "The extracted run_id from the release_handle" |
| 12 | + value: ${{ steps.parse.outputs.run_id }} |
| 13 | + release_tag: |
| 14 | + description: "The extracted release_tag from the release_handle" |
| 15 | + value: ${{ steps.parse.outputs.release_tag }} |
| 16 | + workflow_uuid: |
| 17 | + description: "The extracted workflow_uuid from the release_handle" |
| 18 | + value: ${{ steps.parse.outputs.workflow_uuid }} |
| 19 | + release_type: |
| 20 | + description: "The extracted release_type from the release_handle" |
| 21 | + value: ${{ steps.parse.outputs.release_type }} |
| 22 | + |
| 23 | +runs: |
| 24 | + using: "composite" |
| 25 | + steps: |
| 26 | + - name: Parse release handle |
| 27 | + id: parse |
| 28 | + shell: bash |
| 29 | + run: | |
| 30 | + release_handle='${{ inputs.release_handle }}' |
| 31 | +
|
| 32 | + # Validate that the input is valid JSON |
| 33 | + if ! echo "$release_handle" | jq . >/dev/null 2>&1; then |
| 34 | + echo "Error: release_handle is not valid JSON" |
| 35 | + echo "Release handle content: $release_handle" |
| 36 | + exit 1 |
| 37 | + fi |
| 38 | +
|
| 39 | + echo "Parsing release handle..." |
| 40 | + echo "Available fields: $(echo "$release_handle" | jq -r 'keys | join(", ")')" |
| 41 | +
|
| 42 | + # Extract all known fields |
| 43 | + run_id=$(echo "$release_handle" | jq -r '.run_id // empty') |
| 44 | + release_tag=$(echo "$release_handle" | jq -r '.release_tag // empty') |
| 45 | + workflow_uuid=$(echo "$release_handle" | jq -r '.workflow_uuid // empty') |
| 46 | + release_type=$(echo "$release_handle" | jq -r '.release_type // empty') |
| 47 | +
|
| 48 | + # Validate that run_id exists and is a number (required field) |
| 49 | + if [ -z "$run_id" ]; then |
| 50 | + echo "Error: run_id not found in release_handle" |
| 51 | + echo "Release handle content: $release_handle" |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | +
|
| 55 | + if ! [[ "$run_id" =~ ^[0-9]+$ ]]; then |
| 56 | + echo "Error: run_id is not a valid number: $run_id" |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | +
|
| 60 | + # Output all extracted fields |
| 61 | + echo "Extracted fields:" |
| 62 | + echo " run_id: $run_id" |
| 63 | + echo " release_tag: $release_tag" |
| 64 | + echo " workflow_uuid: $workflow_uuid" |
| 65 | + echo " release_type: $release_type" |
| 66 | +
|
| 67 | + # Set outputs |
| 68 | + echo "run_id=$run_id" >> $GITHUB_OUTPUT |
| 69 | + [ -n "$release_tag" ] && echo "release_tag=$release_tag" >> $GITHUB_OUTPUT |
| 70 | + [ -n "$workflow_uuid" ] && echo "workflow_uuid=$workflow_uuid" >> $GITHUB_OUTPUT |
| 71 | + [ -n "$release_type" ] && echo "release_type=$release_type" >> $GITHUB_OUTPUT |
0 commit comments