Skip to content

Commit 5e1f0c0

Browse files
authored
docs: recipe for GHA generate (#696)
* docs: recipe for GHA generate Signed-off-by: Henry Schreiner <[email protected]> * Update docs/cookbook.rst --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent 720f1ea commit 5e1f0c0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/cookbook.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,35 @@ Even more so with a sprinkling of Nox:
131131
session.run("git", "push", "--tags", external=True)
132132
133133
Now a simple ``nox -s release -- patch`` will automate your release (provided you have Bump2Version set up to change your files). This is especially powerful if you have a CI/CD pipeline set up!
134+
135+
136+
Generating a matrix with GitHub Actions
137+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
138+
139+
Nox knows what sessions it needs to run. Why not tell GitHub Actions what jobs to run dynamically? Using the ``--json`` flag and a bit of json processing, it's easy:
140+
141+
.. code-block:: yaml
142+
143+
jobs:
144+
generate-jobs:
145+
runs-on: ubuntu-latest
146+
outputs:
147+
session: ${{ steps.set-matrix.outputs.session }}
148+
steps:
149+
- uses: actions/checkout@v3
150+
- uses: wntrblm/nox@main
151+
- id: set-matrix
152+
shell: bash
153+
run: echo session=$(nox --json -l | jq -c '[.[].session]') | tee --append $GITHUB_OUTPUT
154+
checks:
155+
name: Session ${{ matrix.session }}
156+
needs: [generate-jobs]
157+
runs-on: ubuntu-latest
158+
strategy:
159+
fail-fast: false
160+
matrix:
161+
session: ${{ fromJson(needs.generate-jobs.outputs.session) }}
162+
steps:
163+
- uses: actions/checkout@v3
164+
- uses: wntrblm/nox@main
165+
- run: nox -s '${{ matrix.session }}'

0 commit comments

Comments
 (0)