GitHub Action to lint Lunar Linux module files using llint.
Automatically detects changed module directories (containing DETAILS or DEPENDS files) and runs llint --path on each.
This action uses a two-workflow design so that lint errors can be posted as PR comments even on fork PRs, without granting write access to untrusted code.
Copy both files from examples/ into your repo's .github/workflows/:
name: Lint Modules
on:
pull_request:
push:
branches: [master]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: lunar-linux/lunar-llint-action@v1name: Lint Comment
on:
workflow_run:
workflows: [Lint Modules]
types: [completed]
permissions:
pull-requests: write
actions: read
jobs:
comment:
if: >-
github.event.workflow_run.event == 'pull_request'
&& github.event.workflow_run.conclusion == 'failure'
runs-on: ubuntu-latest
steps:
- name: Download lint output
uses: actions/download-artifact@v4
with:
name: llint-output
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Find PR number
id: pr
env:
GH_TOKEN: ${{ github.token }}
run: |
head_sha=${{ github.event.workflow_run.head_sha }}
pr=$(gh pr list --repo "${{ github.repository }}" --state open \
--json number,headRefOid \
--jq ".[] | select(.headRefOid == \"$head_sha\") | .number")
echo "number=$pr" >> "$GITHUB_OUTPUT"
- name: Post comment
if: steps.pr.outputs.number != ''
env:
GH_TOKEN: ${{ github.token }}
run: |
errors=$(grep -vE '^::(group|endgroup)::' llint-output.txt | grep -v '^$' || true)
cat > /tmp/comment.md <<'COMMENT_EOF'
## llint found issues
The following lint errors were found in this PR:
```
COMMENT_EOF
echo "$errors" >> /tmp/comment.md
cat >> /tmp/comment.md <<'COMMENT_EOF'
```
Run `llint --path <module-dir> --fix` locally to auto-fix fixable issues.
COMMENT_EOF
gh pr comment "${{ steps.pr.outputs.number }}" \
--repo "${{ github.repository }}" \
--body-file /tmp/comment.mdNote:
fetch-depth: 0is required so the action can diff against the base commit to find changed files.
PRs from forks get a read-only GITHUB_TOKEN — they can't post comments. The workflow_run workflow triggers in the base repo's context with write permissions, but never checks out or executes fork code. It only reads the lint output artifact (a text file) and posts it as a comment. This is the GitHub-recommended pattern for safely commenting on fork PRs.
Contributors can fix issues locally by running llint --path <module-dir> --fix.
| Input | Default | Description |
|---|---|---|
version |
latest |
llint release tag to use (e.g. 2026.2) |
max-line-length |
120 |
Maximum line length for heredoc text in DETAILS |
- Downloads the
llintbinary from the lunar-tools releases - Diffs changed files between base and head commits
- Deduplicates directories and filters to those containing
DETAILSorDEPENDS - Runs
llint --path <dir>on each, grouping output per module - Uploads lint output as an artifact (on failure)
- A separate
workflow_runworkflow picks up the artifact and posts a PR comment - Exits non-zero if any module has lint errors