|
17 | 17 | required: false |
18 | 18 | default: "" |
19 | 19 | type: string |
| 20 | + max_versions: |
| 21 | + description: Maximum number of version tags to build for this manual run |
| 22 | + required: false |
| 23 | + default: "1" |
| 24 | + type: string |
20 | 25 |
|
21 | 26 | env: |
22 | 27 | IMAGE_NAME: ${{ inputs.image_name || vars.IMAGE_NAME || 'nikolaik/python-nodejs' }} |
|
31 | 36 | runs-on: ubuntu-latest |
32 | 37 | needs: [test] |
33 | 38 | outputs: |
34 | | - version_matrix: ${{ steps.set-matrix.outputs.matrix }} |
35 | | - arch_matrix: ${{ steps.set-matrix.outputs.arch_matrix }} |
| 39 | + version_matrix: ${{ steps.filter-matrix.outputs.version_matrix }} |
| 40 | + arch_matrix: ${{ steps.filter-matrix.outputs.arch_matrix }} |
36 | 41 | steps: |
37 | 42 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
38 | 43 | with: |
|
45 | 50 | run: | |
46 | 51 | FORCE=$(if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.force }}" == "true" ]]; then echo "--force"; elif git log --pretty=format:"%s" HEAD^..HEAD | grep -q '\[force\]'; then echo "--force"; else echo ""; fi) |
47 | 52 | uv run dpn $FORCE build-matrix --event ${{ github.event_name }} |
| 53 | + - name: Filter build matrix for manual runs |
| 54 | + id: filter-matrix |
| 55 | + run: | |
| 56 | + version_matrix='${{ steps.set-matrix.outputs.matrix }}' |
| 57 | + arch_matrix='${{ steps.set-matrix.outputs.arch_matrix }}' |
| 58 | + max_versions='${{ github.event_name == 'workflow_dispatch' && inputs.max_versions || '0' }}' |
| 59 | +
|
| 60 | + if [[ -z "${version_matrix}" ]]; then |
| 61 | + echo "version_matrix=" >> "$GITHUB_OUTPUT" |
| 62 | + echo "arch_matrix=" >> "$GITHUB_OUTPUT" |
| 63 | + exit 0 |
| 64 | + fi |
| 65 | +
|
| 66 | + filtered_version_matrix="$(jq -cn \ |
| 67 | + --argjson matrix "${version_matrix}" \ |
| 68 | + --arg max_versions "${max_versions}" ' |
| 69 | + ($matrix.include |
| 70 | + | if ($max_versions | tonumber) > 0 then .[:($max_versions | tonumber)] else . end |
| 71 | + ) as $include |
| 72 | + | if ($include | length) == 0 then empty else {include: $include} end |
| 73 | + ')" |
| 74 | +
|
| 75 | + if [[ -z "${filtered_version_matrix}" ]]; then |
| 76 | + echo "version_matrix=" >> "$GITHUB_OUTPUT" |
| 77 | + echo "arch_matrix=" >> "$GITHUB_OUTPUT" |
| 78 | + exit 0 |
| 79 | + fi |
| 80 | +
|
| 81 | + filtered_arch_matrix="$(jq -cn \ |
| 82 | + --argjson matrix "${arch_matrix}" \ |
| 83 | + --argjson selected "${filtered_version_matrix}" ' |
| 84 | + ($selected.include | map(.key)) as $keys |
| 85 | + | {include: ($matrix.include | map(select(.key as $key | $keys | index($key))))} |
| 86 | + ')" |
| 87 | +
|
| 88 | + echo "version_matrix=${filtered_version_matrix}" >> "$GITHUB_OUTPUT" |
| 89 | + echo "arch_matrix=${filtered_arch_matrix}" >> "$GITHUB_OUTPUT" |
48 | 90 |
|
49 | 91 |
|
50 | 92 | build-arch: |
|
0 commit comments