Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: manual build arch parsing (#1454) #1456

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,47 @@ on:
description: "Custom Builder"
required: false
default: ""
architecture:
description: "Architecture"
required: false
default: all
type: string



jobs:
parse:
outputs:
pkgs: ${{ steps.parsing.outputs.pkgs }}
builder: ${{ inputs.custom_builder }}
arch: ${{ steps.parsing.outputs.arch }}
runs-on: "ubuntu-latest"
steps:
- name: Parse Input
id: parsing
run: echo "${{ inputs.packages }}" | sed 's/ /\n/g' | sed 's/$/\//g' | jq -R . | jq -s . | jq -c . | sed 's/^/pkgs=/' >> $GITHUB_OUTPUT
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: ["rawhide"]
arch: ${{ output.builder == "x86-64-lg" && ["x86_64"] || ["x86_64", "aarch64"] }}
arch: ${{ fromJson(needs.parse.outputs.arch) }}
fail-fast: false
runs-on: ${{ matrix.arch == 'aarch64' && 'ARM64' || output.builder && output.builder || 'ubuntu-latest' }}
runs-on: ${{ matrix.arch == 'aarch64' && 'ARM64' || needs.parse.outputs.builder && needs.parse.outputs.builder || 'ubuntu-latest' }}
container:
image: ghcr.io/terrapkg/builder:f${{ matrix.version }}
options: --cap-add=SYS_ADMIN --privileged
Expand Down
Loading