-
Notifications
You must be signed in to change notification settings - Fork 30
ci: Add GitHub action linting workflow #749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,25 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
name: GitHub action linting | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
on: | ||||||||||||||||||||||||||||||||||||||||||||||
pull_request: | ||||||||||||||||||||||||||||||||||||||||||||||
paths: | ||||||||||||||||||||||||||||||||||||||||||||||
- '.github/workflows/**' | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
permissions: | ||||||||||||||||||||||||||||||||||||||||||||||
contents: read | ||||||||||||||||||||||||||||||||||||||||||||||
pull-requests: write | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
jobs: | ||||||||||||||||||||||||||||||||||||||||||||||
actionlint: | ||||||||||||||||||||||||||||||||||||||||||||||
name: actionlint | ||||||||||||||||||||||||||||||||||||||||||||||
runs-on: ubuntu-24.04 | ||||||||||||||||||||||||||||||||||||||||||||||
steps: | ||||||||||||||||||||||||||||||||||||||||||||||
- name: Checkout code | ||||||||||||||||||||||||||||||||||||||||||||||
uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Pin actions/checkout to a commit SHA and avoid persisting credentials For supply-chain hardening, could we pin to a specific commit SHA and avoid persisting credentials? Also, shallow history can confuse diff-based annotations; consider fetching full history (or at least the merge base), wdyt? Example: - - name: Checkout code
- uses: actions/checkout@v4
+ - name: Checkout code
+ uses: actions/checkout@<commit-sha-for-v4>
+ with:
+ persist-credentials: false
+ fetch-depth: 0 I can fetch the current recommended SHA if helpful. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||
- name: Run actionlint | ||||||||||||||||||||||||||||||||||||||||||||||
uses: reviewdog/[email protected] | ||||||||||||||||||||||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||||||||||||||||||||||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||
reporter: github-pr-review | ||||||||||||||||||||||||||||||||||||||||||||||
level: error | ||||||||||||||||||||||||||||||||||||||||||||||
|
uses: reviewdog/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
reporter: github-pr-review | |
level: error | |
- name: Run actionlint | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: reviewdog/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
reporter: github-pr-review | |
level: error | |
fail_on_error: true | |
- name: Run actionlint (checks for non-PR events) | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: reviewdog/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
reporter: github-check | |
level: error | |
fail_on_error: true |
🧰 Tools
🪛 GitHub Check: CodeQL
[warning] 15-25: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}
🤖 Prompt for AI Agents
In .github/workflows/actionlint.yml around lines 21-25, the action uses a fixed
reporter that fails on push events; change the reporter to pick github-pr-review
for pull_request events and github-check for others using a GitHub Actions
expression (e.g. reporter: ${{ github.event_name == 'pull_request' &&
'github-pr-review' || 'github-check' }}), and add the action input
fail_on_error: true so the job fails when actionlint finds errors.
Uh oh!
There was an error while loading. Please reload this page.