php-fpm: guess we're using javascript now, that can't go wrong
Some checks failed
php-fpm-build / lanes (push) Failing after 54s
php-fpm-build / build (push) Has been skipped

This commit is contained in:
Elijah Duffy
2025-12-07 23:59:01 -08:00
parent cc2a467c17
commit d26be40134

View File

@@ -29,14 +29,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 # Fetch all history for accurate change detection fetch-depth: 0
- name: Get all PHP lanes
id: get-lanes
run: |
lanes=$(find php-fpm -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | jq -R . | jq -s .)
echo "lanes=$lanes" >> $GITHUB_OUTPUT
shell: bash
- name: Get changed files - name: Get changed files
id: changed-files id: changed-files
@@ -47,51 +40,61 @@ jobs:
shared/php-fpm/** shared/php-fpm/**
.github/workflows/php-fpm.yml .github/workflows/php-fpm.yml
- name: Determine lanes to build - name: Get all PHP lanes
id: set-matrix id: get-lanes
shell: bash
run: | run: |
all_lanes='${{ steps.get-lanes.outputs.lanes }}' echo "lanes=$(find php-fpm -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | jq -R . | jq -s .)" >> $GITHUB_OUTPUT
req_lane="${{ github.event.inputs.lane }}" shell: bash
changed_files="${{ steps.changed-files.outputs.all_changed_files }}"
lanes_to_build="[]" - name: Get changed PHP lanes
build_all=false id: changed-lanes
run: |
changed_lanes=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep '^php-fpm/' | cut -d'/' -f2 | sort -u | jq -R . | jq -s 'if . == [] then [] else . end')
echo "lanes=${changed_lanes:-[]}" >> $GITHUB_OUTPUT
shell: bash
# 1. Handle workflow_dispatch input - name: Check for changes requiring all lanes to be built
if [[ -n "$req_lane" ]]; then id: build-all-check
if [[ "$req_lane" == "all" ]]; then run: |
build_all=true for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
else if [[ "$file" == ".github/workflows/php-fpm.yml" || "$file" == shared/php-fpm/* ]]; then
lanes_to_build="[\"$req_lane\"]" echo "build_all=true" >> $GITHUB_OUTPUT
exit 0
fi fi
else done
# 2. Check for changes that trigger a full rebuild echo "build_all=false" >> $GITHUB_OUTPUT
for file in $changed_files; do shell: bash
if [[ "$file" == ".github/workflows/php-fpm.yml" || "$file" == shared/php-fpm/* ]]; then
build_all=true
break
fi
done
fi
# 3. Build matrix based on flags - name: Generate matrix for build job
if [[ "$build_all" == true ]]; then id: set-matrix
lanes_to_build="$all_lanes" uses: actions/github-script@v7
elif [[ -n "$changed_files" && "$lanes_to_build" == "[]" ]]; then with:
# 4. If not a full build, determine changed lanes script: |
lanes=$(echo "$changed_files" | tr ' ' '\n' | grep '^php-fpm/' | cut -d'/' -f2 | sort -u | jq -R . | jq -s .) const req_lane = "${{ github.event.inputs.lane }}";
if [[ -n "$lanes" && "$lanes" != "[]" ]]; then const build_all = ${{ steps.build-all-check.outputs.build_all }};
lanes_to_build="$lanes" const all_lanes = JSON.parse('${{ steps.get-lanes.outputs.lanes }}');
fi const changed_lanes = JSON.parse('${{ steps.changed-lanes.outputs.lanes }}');
fi
matrix="{\"lane\":$lanes_to_build}" let lanes_to_build = [];
echo "matrix=$matrix" >> $GITHUB_OUTPUT
if (req_lane) {
if (req_lane === "all") {
lanes_to_build = all_lanes;
} else {
lanes_to_build = [req_lane];
}
} else if (build_all) {
lanes_to_build = all_lanes;
} else {
lanes_to_build = changed_lanes;
}
return { lane: lanes_to_build };
result-encoding: json
build: build:
needs: lanes needs: lanes
if: ${{ needs.lanes.outputs.matrix != '{"lane":[]}' }} if: ${{ needs.lanes.outputs.matrix.lane[0] }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false