Skip to content

Commit 24ca039

Browse files
authored
docs: add example if statement (with single-quote gotcha)
1 parent c8475b5 commit 24ca039

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

docs/advanced-usage.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ jobs:
204204
205205
### Matrix Testing
206206
207-
Using `setup-python` it's possible to use [matrix syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) to install several versions of Python or PyPy:
207+
Using `setup-python` it's possible to use the [matrix syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) to install several versions of Python or PyPy:
208208

209209
```yaml
210210
jobs:
@@ -233,7 +233,7 @@ jobs:
233233
strategy:
234234
matrix:
235235
os: [ubuntu-latest, macos-latest, windows-latest]
236-
python-version: ['2.7', '3.7', '3.8', '3.9', '3.10', 'pypy2.7', 'pypy3.8']
236+
python-version: ['2.7', '3.7', '3.8', '3.9', '3.10', '*', 'pypy2.7', 'pypy3.8']
237237
exclude:
238238
- os: macos-latest
239239
python-version: '3.8'
@@ -246,9 +246,24 @@ jobs:
246246
with:
247247
python-version: ${{ matrix.python-version }}
248248
- name: Display Python version
249+
if: ${{ python-version != 'pypy2.7' && python-version != '*' }} # in GitHub workflows if statements, use single-quotes (not double-quotes) in expressions to test input `python-version`
249250
run: python --version
250251
```
251252
253+
```yaml
254+
strategy:
255+
fail-fast: false
256+
matrix:
257+
python-version: ["3.7", "3.8", "3.10", "*", "3.12-dev"]
258+
steps:
259+
- uses: actions/checkout@v3
260+
- uses: actions/setup-python@v4
261+
with:
262+
python-version: ${{ matrix.python-version }}
263+
264+
run: python my_script.py
265+
```
266+
252267
## Using the `python-version-file` input
253268

254269
`setup-python` action can read Python or PyPy version from a version file. `python-version-file` input is used for specifying the path to the version file. If the file that was supplied to `python-version-file` input doesn't exist, the action will fail with error.

0 commit comments

Comments
 (0)