Skip to content

Commit 35be640

Browse files
Feat: Add path_prefix output for downstream actions
When using path_prefix to build projects in subdirectories, downstream actions like python-test-action, python-audit-action, and python-sbom-action also need the same path_prefix value. This change outputs path_prefix so workflows can pass it to later jobs via needs.python-build.outputs.path_prefix. Fixes: #138 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
1 parent d713e71 commit 35be640

2 files changed

Lines changed: 51 additions & 6 deletions

File tree

README.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,54 @@ permissions:
201201

202202
<!-- markdownlint-disable MD013 -->
203203

204-
| Variable Name | Description |
205-
| -------------------- | ---------------------------------------------- |
206-
| build_python_version | Python version used to perform build |
207-
| matrix_json | Project supported Python versions as JSON |
208-
| artefact_name | Project name used for build artefacts |
209-
| artefact_path | Full path to build artefacts directory |
204+
| Variable Name | Description |
205+
| -------------------- | ------------------------------------------------- |
206+
| build_python_version | Python version used to perform build |
207+
| matrix_json | Project supported Python versions as JSON |
208+
| artefact_name | Project name used for build artefacts |
209+
| artefact_path | Full path to build artefacts directory |
210+
| path_prefix | Path prefix to Python project (for downstream) |
211+
212+
<!-- markdownlint-enable MD013 -->
213+
214+
### Using path_prefix with Downstream Actions
215+
216+
When your Python project lives in a subdirectory (not the repository
217+
root), you must pass `path_prefix` to both this action and any downstream
218+
actions like `python-test-action`, `python-audit-action`, and
219+
`python-sbom-action`. The `path_prefix` output makes this easier by passing
220+
the value through for use in later jobs:
221+
222+
<!-- markdownlint-disable MD013 -->
223+
224+
```yaml
225+
jobs:
226+
python-build:
227+
runs-on: ubuntu-latest
228+
outputs:
229+
matrix_json: "${{ steps.python-build.outputs.matrix_json }}"
230+
path_prefix: "${{ steps.python-build.outputs.path_prefix }}"
231+
steps:
232+
- uses: actions/checkout@v4
233+
- name: 'Build Python project'
234+
id: python-build
235+
uses: lfreleng-actions/python-build-action@main
236+
with:
237+
path_prefix: 'my-python-project/'
238+
239+
python-tests:
240+
runs-on: ubuntu-latest
241+
needs: python-build
242+
strategy:
243+
matrix: "${{ fromJSON(needs.python-build.outputs.matrix_json) }}"
244+
steps:
245+
- uses: actions/checkout@v4
246+
- name: 'Run tests'
247+
uses: lfreleng-actions/python-test-action@main
248+
with:
249+
python_version: ${{ matrix.python-version }}
250+
path_prefix: ${{ needs.python-build.outputs.path_prefix }}
251+
```
210252

211253
<!-- markdownlint-enable MD013 -->
212254

action.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ outputs:
110110
artefact_path:
111111
description: 'Full path to build artefacts directory'
112112
value: ${{ steps.build_summary.outputs.artefact_path }}
113+
path_prefix:
114+
description: 'Path prefix to Python project (pass to downstream actions)'
115+
value: ${{ inputs.path_prefix }}
113116

114117
runs:
115118
using: 'composite'

0 commit comments

Comments
 (0)