You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Strictly check available contexts in `${{ }}` placeholders following the ['Context availability' table](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#context-availability) in the official document.
5
-
- For example, `jobs.<job>.env` allows `github` context but `jobs.<job>.services.<service>.env` doesn't allow any contexts. Now actionlint can catch the mistake.
5
+
- For example, `jobs.<job_id>.defaults.run.shell` allows `env` context but `shell` workflow keys in other places allow no context.
6
6
```yaml
7
+
defaults:
8
+
run:
9
+
# ERROR: No context is available here
10
+
shell: ${{ env.SHELL }}
11
+
7
12
jobs:
8
13
test:
9
14
runs-on: ubuntu-latest
10
-
env:
11
-
# OK. `github` context is available here.
12
-
COMMIT_SHA: ${{ github.sha }}
13
-
services:
14
-
redis:
15
-
image: redis
16
-
env:
17
-
# ERROR: No context is available here.
18
-
COMMIT_SHA: ${{ github.sha }}
15
+
defaults:
16
+
run:
17
+
# OK: 'env' context is available here
18
+
shell: ${{ env.SHELL }}
19
19
steps:
20
-
- ...
20
+
- run: echo hello
21
+
# ERROR: No context is available here
22
+
shell: ${{ env.SHELL}}
21
23
```
22
24
- Check a string literal passed to `fromJSON()` call. This pattern is [popular](https://github.com/search?q=fromJSON%28%27+lang%3Ayaml&type=code) to create array or object constants because GitHub Actions does not provide the literal syntax for them. See the [document](https://github.com/rhysd/actionlint/blob/main/docs/checks.md#contexts-and-built-in-functions) for more details. ([#464](https://github.com/rhysd/actionlint/issues/464))
23
25
```yaml
@@ -796,7 +798,7 @@
796
798
- Allow workflow calls are available in matrix jobs. See [the official announcement](https://github.blog/changelog/2022-08-22-github-actions-improvements-to-reusable-workflows-2/) for more details. ([#197](https://github.com/rhysd/actionlint/issues/197))
797
799
```yaml
798
800
jobs:
799
-
ReusableMatrixJobForDeployment:
801
+
ReuseableMatrixJobForDeployment:
800
802
strategy:
801
803
matrix:
802
804
target: [dev, stage, prod]
@@ -929,7 +931,7 @@
929
931
```
930
932
- Fix usage of local actions (`uses: ./path/to/action`) was not checked when multiple workflow files were passed to `actionlint` command. ([#173](https://github.com/rhysd/actionlint/issues/173))
931
933
- Allow `description:` is missing in `secrets:` of reusable workflow call definition since it is optional. ([#174](https://github.com/rhysd/actionlint/issues/174))
932
-
- Fix type of property of `github.event.inputs` is string unlike `inputs` context. See [the document](https://github.com/rhysd/actionlint/blob/main/docs/checks.md#workflow-dispatch-event-validation) for more details. ([#181](https://github.com/rhysd/actionlint/issues/181))
934
+
- Fix type of propery of `github.event.inputs` is string unlike `inputs` context. See [the document](https://github.com/rhysd/actionlint/blob/main/docs/checks.md#workflow-dispatch-event-validation) for more details. ([#181](https://github.com/rhysd/actionlint/issues/181))
Copy file name to clipboardExpand all lines: docs/checks.md
+27-21Lines changed: 27 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2626,8 +2626,10 @@ Example input:
2626
2626
```yaml
2627
2627
on: push
2628
2628
2629
-
env:
2630
-
NAME: rhysd
2629
+
defaults:
2630
+
run:
2631
+
# ERROR: No context is available here
2632
+
shell: ${{ env.SHELL }}
2631
2633
2632
2634
jobs:
2633
2635
test:
@@ -2639,19 +2641,19 @@ jobs:
2639
2641
# ERROR: 'runner' context is not available here
2640
2642
- ${{ runner.temp }}
2641
2643
runs-on: ubuntu-latest
2644
+
defaults:
2645
+
run:
2646
+
# OK: 'env' context is available here
2647
+
shell: ${{ env.SHELL }}
2642
2648
env:
2643
2649
# ERROR: 'env' context is not available here
2644
-
NAME: ${{ env.NAME }}
2645
-
services:
2646
-
redis:
2647
-
image: redis
2648
-
env:
2649
-
# ERROR: No context is allowed here
2650
-
COMMIT_SHA: ${{ github.sha }}
2650
+
FOO: ${{ env.BAR }}
2651
2651
steps:
2652
2652
- env:
2653
2653
# OK: 'env' context is available here
2654
-
NAME: ${{ env.NAME }}
2654
+
FOO: ${{ env.BAR }}
2655
+
# ERROR: No context is available here
2656
+
shell: ${{ env.SHELL}}
2655
2657
# ERROR: 'success()' function is not available here
2656
2658
run: echo 'Success? ${{ success() }}'
2657
2659
# OK: 'success()' function is available here
@@ -2661,25 +2663,29 @@ jobs:
2661
2663
Output:
2662
2664
2663
2665
```
2664
-
test.yaml:14:17: context "runner" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details [expression]
2666
+
test.yaml:6:16: context "env" is not allowed here. no context is available here. see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details [expression]
2667
+
|
2668
+
6 | shell: ${{ env.SHELL }}
2669
+
| ^~~~~~~~~
2670
+
test.yaml:16:17: context "runner" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details [expression]
2665
2671
|
2666
-
14 | - ${{ runner.temp }}
2672
+
16 | - ${{ runner.temp }}
2667
2673
| ^~~~~~~~~~~
2668
-
test.yaml:18:17: context "env" is not allowed here. available contexts are "github", "inputs", "matrix", "needs", "secrets", "strategy", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details [expression]
2674
+
test.yaml:24:16: context "env" is not allowed here. available contexts are "github", "inputs", "matrix", "needs", "secrets", "strategy", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details [expression]
2669
2675
|
2670
-
18 | NAME: ${{ env.NAME }}
2671
-
| ^~~~~~~~
2672
-
test.yaml:24:27: context "github" is not allowed here. no context is available here. see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details [expression]
2676
+
24 | FOO: ${{ env.BAR }}
2677
+
| ^~~~~~~
2678
+
test.yaml:30:20: context "env" is not allowed here. no context is available here. see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details [expression]
2673
2679
|
2674
-
24 | COMMIT_SHA: ${{ github.sha }}
2675
-
| ^~~~~~~~~~
2676
-
test.yaml:30:33: calling function "success" is not allowed here. "success" is only available in "jobs.<job_id>.if", "jobs.<job_id>.steps.if". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details [expression]
2680
+
30 | shell: ${{ env.SHELL}}
2681
+
| ^~~~~~~~~~~
2682
+
test.yaml:32:33: calling function "success" is not allowed here. "success" is only available in "jobs.<job_id>.if", "jobs.<job_id>.steps.if". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details [expression]
0 commit comments