Skip to content

Commit

Permalink
fix: manual parsing using jq
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Jul 9, 2024
1 parent 0210485 commit 06bf35a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
description: "Custom Builder"
required: false
default: ""
architecture:
description: "Architecture"
required: false
default: all
type: string


jobs:
parse:
Expand All @@ -22,14 +28,24 @@ jobs:
run: |
echo "${{ inputs.packages }}" | sed 's/ /\n/g' | sed 's/$/\//g' | jq -R . | jq -s . | jq -c . | sed 's/^/pkgs=/' >> $GITHUB_OUTPUT
echo "builder=${{ inputs.custom_builder }}" >> $GITHUB_OUTPUT
arch="${{ inputs.architecture }}"
# Convert to json array using jq
# if arch is not all, convert to array
if [ "$arch" != "all" ]; then
# jq, array with single element as string
arch=$(echo $arch | sed 's/,/\n/g')
echo "arch=$(echo $arch | jq -Rs 'split("\n")' | jq 'map(select(length > 0))' | jq -c .)" >> $GITHUB_OUTPUT
else
echo "arch=$(echo '["aarch64", "x86_64"]' | jq -c .)" >> $GITHUB_OUTPUT
fi
build:
needs: parse
strategy:
matrix:
pkg: ${{ fromJson(needs.parse.outputs.pkgs) }}
version: ["40"]
arch: ${{ needs.parse.outputs.builder == "x86-64-lg" && ["x86_64"] || ["x86_64", "aarch64"] }}
arch: ${{ fromJson(needs.parse.outputs.arch) }}
fail-fast: false
runs-on: ${{ matrix.arch == 'aarch64' && 'ARM64' || needs.parse.outputs.builder && needs.parse.outputs.builder || 'ubuntu-latest' }}
container:
Expand Down

0 comments on commit 06bf35a

Please sign in to comment.