github-action/prefer-step-uses-style
Enforce the style of job step
uses.
📖 Rule Details
This rule enforces a consistent style for job step uses.
yaml
name: Release
jobs:
test:
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4.2.0correct
yaml
name: Release
jobs:
test:
steps:
- uses: actions/checkout@main
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3incorrect
🔧 Options
Default style is set to release.
ts
type AllowedStyle = 'release' | 'commit' | 'branch'
type JobIdCasingOptions = [
'error' | 'warn' | 'off' | 2 | 1 | 0,
(
| AllowedStyle
| ({
[key in AllowedStyle]?: boolean
} & {
ignores?: string[]
/**
* @default false
*/
allowRepository?: boolean
/**
* @default false
*/
allowDocker?: boolean
})
),
]"release" (default)
Examples of correct code for this rule with default option:
yaml
name: Release
jobs:
test:
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4.2.0correct
Examples of incorrect code for this rule with default option:
yaml
name: Release
jobs:
test:
steps:
# `branch` style
- uses: actions/checkout@main
# `commit` style
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
# same repository
- uses: ./.github/actions/hello-world-action
# docker action
- uses: docker://alpine:3.8incorrect
Custom options
json
{
"commit": true,
"allowDocker": true,
"ignores": ["actions/checkout@main"]
}Examples of correct code for custom option above:
yaml
name: Release
jobs:
test:
steps:
# ignored
- uses: actions/checkout@main
# `commit` style
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
# docker action
- uses: docker://alpine:3.8correct
Examples of incorrect code for custom option above:
yaml
name: Release
jobs:
test:
steps:
# `release` style
- uses: actions/checkout@v4
- uses: actions/checkout@v4.2.0
# same repository
- uses: ./.github/actions/hello-world-actionincorrect
📚 Further reading
docker
When uses starts with docker://, it is considered a docker action.
repository
When uses starts with ./, it is considered a same-repository action.
commit
When uses has 40 characters after @, it is considered a commit style action.
release
When uses starts with v after @, it is considered a release style action.
branch
Fallback style when none match above.
Reference
🚀 Version
This rule was introduced in eslint-plugin-github-action v0.0.7