@@ -100,8 +100,6 @@ adjust the Python versions to suit your taste; you can also test on different
100100OS's if you'd like by adding them to the matrix and inputting them into
101101` runs-on` .
102102
103- {% raw %}
104-
105103` ` ` yaml
106104tests:
107105 runs-on: ubuntu-latest
@@ -131,8 +129,6 @@ tests:
131129 run: uv run pytest
132130` ` `
133131
134- {% endraw %}
135-
136132A few things to note from above :
137133
138134The matrix should contain the versions you are interested in. You can also test
@@ -229,15 +225,11 @@ actions have outputs, and bash actions can manually write to output:
229225 run: echo "something=true" >> $GITHUB_OUTPUT
230226` ` `
231227
232- {% raw %}
233-
234228You can now refer to this step in a later step with
235229` ${{ steps.someid.something }}` . You also can get it from another job by using
236230` ${{ needs.<jobname>.outputs.something }}` . The `toJson()` function is useful
237231for inputting JSON - you can even generate matrices dynamically this way!
238232
239- {% endraw %}
240-
241233# ### Pretty output
242234
243235You can write GitHub flavored markdown to `$GITHUB_STEP_SUMMARY`, and it will be
@@ -342,16 +334,12 @@ These are some things you might need.
342334{rr}`GH102` If you add the following, you can ensure only one run per
343335PR/branch happens at a time, cancelling the old run when a new one starts :
344336
345- {% raw %}
346-
347337` ` ` yaml
348338concurrency:
349339 group: ${{ github.workflow }}-${{ github.ref }}
350340 cancel-in-progress: true
351341` ` `
352342
353- {% endraw %}
354-
355343Anything with a matching group name will count in the same group - the ref is
356344the "from" name for the PR. If you want, you can replace `github.ref` with
357345` github.event.pull_request.number || github.sha` ; this will still cancel on PR
@@ -368,8 +356,6 @@ pass).
368356
369357As an example, if you had `lint` and `checks` jobs, use this :
370358
371- {% raw %}
372-
373359` ` ` yaml
374360pass:
375361 if: always()
@@ -381,8 +367,6 @@ pass:
381367 jobs: ${{ toJSON(needs) }}
382368` ` `
383369
384- {% endraw %}
385-
386370We want the job to always run, so we set `if : always()`. Otherwise, it might be
387371skipped if any job it depends on is skipped, and skipped jobs count as "passing"
388372to GitHub's automerge (yikes!). The important part of the job is the `needs:`
@@ -441,8 +425,6 @@ ideally shouldn't change the user's environment; suddenly changing the active
441425Python version might come as a surprise. You can do that, though, using
442426`update-environment : false` with `setup-python` and `pipx`:
443427
444- {% raw %}
445-
446428` ` ` yaml
447429- uses: actions/setup-python@v6
448430 id: python
@@ -457,8 +439,6 @@ Python version might come as a surprise. You can do that, though, using
457439 github.action_path }}' ${{ inputs.some-input }}
458440` ` `
459441
460- {% endraw %}
461-
462442You use the `python-path` output from `setup-python` to get the Python you
463443activated. You use `github.action_path` to get the path to the checked-out
464444action.
510490Otherwise, they look like normal workflows. Then you need another reusable
511491workflow file to decide when to run a specific situation.
512492
513- {% raw %}
514-
515493` ` ` yaml
516494# reusable-change-detection.yml
517495on:
@@ -522,17 +500,13 @@ on:
522500 # More here if you have more situations to detect
523501` ` `
524502
525- {% endraw %}
526-
527503You start by specifying outputs when running this. You'll want one output per
528504situation you want to detect. The value will be output from our
529505` change-detection` job below, and defaults to "false" if we don't output
530506anything.
531507
532508Now, we need our job :
533509
534- {% raw %}
535-
536510` ` ` yaml
537511jobs:
538512 change-detection:
@@ -566,8 +540,6 @@ jobs:
566540 # Add 2 more steps per situation you have to detect
567541` ` `
568542
569- {% endraw %}
570-
571543This has a bit of boilerplate (mostly around passing variables around), but what
572544it's doing is fairly simple. Instead of stepping through it, let's look at what
573545it's trying to do. First, you need to find a list of all changed files in the
@@ -595,8 +567,6 @@ If you have more situations, you just repeat these two steps with different
595567Finally, you write the overarching CI workflow that combines the reusable
596568workflows, something like `ci.yml` :
597569
598- {% raw %}
599-
600570` ` ` yaml
601571on:
602572 workflow_dispatch:
@@ -642,8 +612,6 @@ If you have more situations, add another `${{ ... }}` above, after the first
642612one, and add them to the needs list. This is really just injecting "tests" only
643613if the "tests" job is being skipped into `allowed-skips`.
644614
645- {% endraw %}
646-
647615:::{tip}
648616Some examples of repos using this method are :
649617
@@ -690,16 +658,12 @@ configure Pages.
690658 uses: actions/configure-pages@v6
691659` ` `
692660
693- {% raw %}
694-
695661Notice this action sets an `id:`; this will allow you to use the outputs from
696662this action later; specifically, may want to use
697663` ${{ steps.pages.outputs.base_path }}` when building (you can also get `origin`,
698664` base_url` , or `host` - see the action
699665[config](https://github.com/actions/configure-pages/blob/main/action.yml)).
700666
701- {% endraw %}
702-
703667` ` ` yaml
704668- name: Upload artifact
705669 uses: actions/upload-pages-artifact@v5
@@ -712,8 +676,6 @@ Finally, you'll need to deploy the artifact (named `github-pages`) to Pages. You
712676can make this a custom job with `needs:` pointing at your previous job (in this
713677example, the previous job is called `build`) :
714678
715- {% raw %}
716-
717679` ` ` yaml
718680deploy:
719681 environment:
@@ -727,8 +689,6 @@ deploy:
727689 uses: actions/deploy-pages@v5
728690` ` `
729691
730- {% endraw %}
731-
732692The deploy-pages job gives a `page_url`, which is the same as `base_url` on the
733693configure step, and can be set in the `environment`. If you want to do
734694everything in one job, you only need one of these.
0 commit comments