-
Notifications
You must be signed in to change notification settings - Fork 0
chore(ci): add actionlint + prettier check on PRs #12
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
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,77 @@ | ||||||
| name: Lint | ||||||
|
|
||||||
| # Two roles for this workflow: | ||||||
| # | ||||||
| # 1. Self-test: triggers on pull_request + push to main of *this repo* so that | ||||||
| # typos in the reusable workflows here get caught before they break every | ||||||
| # downstream consumer. | ||||||
| # | ||||||
| # 2. Reusable: other repos can call it via | ||||||
| # jobs: | ||||||
| # lint: | ||||||
| # uses: topcoder1/ci-workflows/.github/workflows/lint.yml@main | ||||||
| # See callers/lint.yml in the templates dir for a copy-paste-ready caller. | ||||||
| # | ||||||
| # What it checks: | ||||||
| # - actionlint on every .github/workflows/*.yml (catches GHA-specific bugs + | ||||||
| # embedded shellcheck for `run:` blocks) | ||||||
| # - prettier --check on the markdown glob (default **/*.md) | ||||||
| # | ||||||
| # Why no husky/lint-staged: this is meant to plug into repos with mixed | ||||||
| # tooling (or none). CI-only enforcement keeps the dependency surface flat. | ||||||
|
|
||||||
| on: | ||||||
| pull_request: | ||||||
| push: | ||||||
| branches: [main] | ||||||
| workflow_call: | ||||||
| inputs: | ||||||
| markdown_glob: | ||||||
| description: "Glob passed to prettier --check. Default '**/*.md'." | ||||||
| required: false | ||||||
| type: string | ||||||
| default: "**/*.md" | ||||||
| run_actionlint: | ||||||
| description: "Run actionlint job. Default true." | ||||||
| required: false | ||||||
| type: boolean | ||||||
| default: true | ||||||
| run_prettier: | ||||||
| description: "Run prettier --check on markdown. Default true." | ||||||
| required: false | ||||||
| type: boolean | ||||||
| default: true | ||||||
|
|
||||||
| permissions: | ||||||
| contents: read | ||||||
|
|
||||||
| jobs: | ||||||
| actionlint: | ||||||
| name: actionlint | ||||||
| if: ${{ github.event_name != 'workflow_call' || inputs.run_actionlint }} | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Download actionlint | ||||||
| id: get_actionlint | ||||||
| run: bash <(curl -s https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) | ||||||
|
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. Supply chain risk: fetching from unpinned This Pin to a specific release tag so the content is immutable:
Suggested change
Or use the official action pinned to a SHA for stronger guarantees: - uses: rhysd/actionlint@11f75d9775d0829b8fdc43df25c96a6e4ba40de1 # v1.7.7(No |
||||||
| shell: bash | ||||||
|
|
||||||
| - name: Run actionlint | ||||||
| run: ${{ steps.get_actionlint.outputs.executable }} -color | ||||||
| shell: bash | ||||||
|
|
||||||
| prettier: | ||||||
| name: prettier (markdown) | ||||||
| if: ${{ github.event_name != 'workflow_call' || inputs.run_prettier }} | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - uses: actions/checkout@v4 | ||||||
|
|
||||||
| - uses: actions/setup-node@v4 | ||||||
| with: | ||||||
| node-version: "20" | ||||||
|
|
||||||
| - name: prettier --check ${{ inputs.markdown_glob || '**/*.md' }} | ||||||
| run: npx --yes prettier@3 --check "${{ inputs.markdown_glob || '**/*.md' }}" | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supply-chain risk: unpinned
main-branch curl | bashThis fetches and executes a script from
rhysd/actionlint'smainbranch with no integrity check. Any commit to that branch — including a compromise — lands immediately in this repo's CI with no review gate.This is especially risky here because
ci-workflowsis a shared-reusable-workflow host: a poisoned actionlint binary could exfiltrate secrets injected by downstream callers.Safer alternatives (in order of preference):
(replace with the current release; pinning to a SHA gives the strongest guarantee)