Build only spec files that were changed in the push
Add a 'changed' job that determines which .spec files were modified using git diff between push before/after SHAs. The build job now uses a dynamic matrix (fromJSON) so only changed specs are built. For workflow_dispatch, all specs are still built.
This commit is contained in:
parent
1e507a71fa
commit
7cbd8b6f3d
1 changed files with 22 additions and 5 deletions
|
|
@ -7,15 +7,32 @@ on:
|
|||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
changed:
|
||||
runs-on: almalinux-10
|
||||
outputs:
|
||||
matrix: ${{ steps.set.outputs.matrix }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Determine changed specs
|
||||
id: set
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
python3 -c "import json; print(json.dumps({'spec': ['sonic-interface-libraries.spec','sonic-win.spec','sonic-workspace.spec']}))"
|
||||
else
|
||||
CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '\.spec$' || true)
|
||||
python3 -c "import json, sys; print(json.dumps({'spec': sys.argv[1].split()}))" "$CHANGED"
|
||||
fi >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
needs: changed
|
||||
runs-on: almalinux-10
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
spec:
|
||||
- sonic-interface-libraries.spec
|
||||
- sonic-win.spec
|
||||
- sonic-workspace.spec
|
||||
matrix: ${{ fromJSON(needs.changed.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue