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
Note that actionlint focuses on catching mistakes in workflow files. If you want some general code style checks, please consider
43
44
using a general YAML checker like [yamllint][].
@@ -2657,6 +2658,78 @@ works as intended.
2657
2658
actionlint checks all `if:` conditions in workflow and reports error when some condition is always evaluated to true due to extra
2658
2659
characters around `${{ }}`.
2659
2660
2661
+
<a name="action-metadata-syntax"></a>
2662
+
## Action metadata syntax validation
2663
+
2664
+
Example workflow input:
2665
+
2666
+
```yaml
2667
+
on: push
2668
+
2669
+
jobs:
2670
+
test:
2671
+
runs-on: ubuntu-latest
2672
+
steps:
2673
+
# actionlint checks an action when it is actually used in a workflow
2674
+
- uses: ./.github/actions/my-invalid-action
2675
+
```
2676
+
2677
+
Example action metadata:
2678
+
2679
+
```yaml
2680
+
# .github/actions/some-action/action.yml
2681
+
2682
+
name: 'My action'
2683
+
author: '...'
2684
+
# ERROR: 'description' section is required
2685
+
2686
+
runs:
2687
+
# ERROR: Node.js runtime version is too old
2688
+
using: 'node14'
2689
+
# ERROR: The source file being run by this action does not exist
2690
+
main: 'this-file-does-not-exist.js'
2691
+
# ERROR: 'env' configuration is only allowed for Docker actions
2692
+
env:
2693
+
SOME_VAR: SOME_VALUE
2694
+
```
2695
+
2696
+
Output:
2697
+
2698
+
```
2699
+
test.yaml:8:15: description is required in metadata of "My action" action at "path/to/.github/actions/my-invalid-action/action.yml" [action]
2700
+
|
2701
+
8 | - uses: ./.github/actions/my-invalid-action
2702
+
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2703
+
test.yaml:8:15: "node14" runner at "runs.using" is unavailable since the Node.js version is too old (14 < 16) in local action "My action" defined at "path/to/.github/actions/my-invalid-action". see https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions [action]
2704
+
|
2705
+
8 | - uses: ./.github/actions/my-invalid-action
2706
+
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2707
+
test.yaml:8:15: file "this-file-does-not-exist.js" does not exist in "path/to/.github/actions/my-invalid-action". it is specified at "main" key in "runs" section in "My action" action [action]
2708
+
|
2709
+
8 | - uses: ./.github/actions/my-invalid-action
2710
+
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2711
+
test.yaml:8:15: "env" is not allowed in "runs" section because "My action" is a JavaScript action. the action is defined at "path/to/.github/actions/my-invalid-action" [action]
2712
+
|
2713
+
8 | - uses: ./.github/actions/my-invalid-action
2714
+
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2715
+
```
2716
+
2717
+
All actions require a metadata file `action.yml` or `aciton.yaml`. The syntax is defined in [the official document][action-metadata-doc].
2718
+
2719
+
actionlint checks metadata files used in workflows and reports errors when they are not following the syntax.
2720
+
2721
+
- `name:`, `description:`, `runs:` sections are required
2722
+
- Runner name at `using:` is one of `composite`, `docker`, `node16`, `node20`
2723
+
- Keys under `runs:` section are correct. Required/Valid keys are different depending on the type of action; Docker action or
2724
+
Composite action or JavaScript action (e.g. `image:` is required for Docker action).
2725
+
- Files specified in some keys under `runs` are existing. For example, JavaScript action defines a script file path for
2726
+
entrypoint at `main:`.
2727
+
2728
+
actionlint checks action metadata files which are used by workflows. Currently it is not supported to specify `action.yml`
2729
+
directly via command line arguments.
2730
+
2731
+
Note that `steps` in Composite action's metadata is not checked at this point. It will be supported in the future.
/test\.yaml:8:15: description is required in metadata of "My action" action at ".+(\\\\|/)my-invalid-action(\\\\|/)action\.yml" \[action\]/
2
+
/test\.yaml:8:15: invalid runner name \"node14\" at runs\.using in \"My action\" action defined at \".+(\\\\|/)actions(\\\\|/)my-invalid-action\"\. valid runners are \"composite\", \"docker\", \"node16\", and \"node20\"\. see https://.+ \[action\]/
3
+
/test\.yaml:8:15: file "this-file-does-not-exist\.js" does not exist in ".+(\\\\|/)my-invalid-action"\. it is specified at "main" key in "runs" section in "My action" action \[action\]/
4
+
/test\.yaml:8:15: "env" is not allowed in "runs" section because "My action" is a JavaScript action\. the action is defined at ".+(\\\\|/)my-invalid-action" \[action\]/
0 commit comments