Skip to content

Commit 52ea053

Browse files
refactor: streamline lint results handling in GitHub Actions workflow (#154)
1 parent 8d04dd6 commit 52ea053

1 file changed

Lines changed: 25 additions & 65 deletions

File tree

.github/workflows/lint-readme.yml

Lines changed: 25 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ jobs:
2323
id: lint
2424
run: |
2525
set -o pipefail
26-
node ./.github/scripts/lint-readme.js | tee gh-cli-readme-lint-results.txt || true
26+
node ./.github/scripts/lint-readme.js | tee lint-results.txt
2727
28-
- name: Upload lint results
29-
if: steps.lint.outcome == 'failure' || steps.lint.outcome == 'success'
30-
uses: actions/upload-artifact@v6
31-
with:
32-
name: gh-cli-readme-lint-results
33-
path: gh-cli-readme-lint-results.txt
28+
- name: Post lint results to job summary
29+
if: always()
30+
run: |
31+
echo "## Lint Results for ./gh-cli/README.md" >> "$GITHUB_STEP_SUMMARY"
32+
echo "" >> "$GITHUB_STEP_SUMMARY"
33+
echo '```' >> "$GITHUB_STEP_SUMMARY"
34+
if [ -f lint-results.txt ]; then
35+
cat lint-results.txt >> "$GITHUB_STEP_SUMMARY"
36+
else
37+
echo "No results available" >> "$GITHUB_STEP_SUMMARY"
38+
fi
39+
echo '```' >> "$GITHUB_STEP_SUMMARY"
3440
3541
lint-scripts-readme:
3642
name: Lint ./scripts/README.md
@@ -46,63 +52,17 @@ jobs:
4652
id: lint
4753
run: |
4854
set -o pipefail
49-
node ./.github/scripts/lint-readme.js ./scripts '##' '# scripts' | tee scripts-readme-lint-results.txt || true
50-
51-
- name: Upload lint results
52-
if: steps.lint.outcome == 'failure' || steps.lint.outcome == 'success'
53-
uses: actions/upload-artifact@v6
54-
with:
55-
name: scripts-readme-lint-results
56-
path: scripts-readme-lint-results.txt
57-
58-
post-results:
59-
name: Post Lint Results as PR Comment
60-
runs-on: ubuntu-latest
61-
if: always()
62-
needs:
63-
- lint-gh-cli-readme
64-
- lint-scripts-readme
65-
permissions:
66-
pull-requests: write
67-
68-
steps:
69-
- name: Download lint results
70-
uses: actions/download-artifact@v7
71-
with:
72-
path: ./lint-results/
55+
node ./.github/scripts/lint-readme.js ./scripts '##' '# scripts' | tee lint-results.txt
7356
74-
- name: Process Lint Results
75-
id: process-results
57+
- name: Post lint results to job summary
58+
if: always()
7659
run: |
77-
echo "## 📋 Lint Results" > comment.md
78-
echo "" >> comment.md
79-
80-
# Function to process lint results
81-
process_lint_results() {
82-
local title="$1"
83-
local file="$2"
84-
85-
echo "### $title" >> comment.md
86-
echo "\`\`\`" >> comment.md
87-
if [ -f "$file" ]; then
88-
cat "$file" >> comment.md
89-
else
90-
echo "❌ No results available" >> comment.md
91-
fi
92-
echo "\`\`\`" >> comment.md
93-
echo "" >> comment.md
94-
}
95-
96-
# Process both README results
97-
process_lint_results "⚡ ./gh-cli scripts" "./lint-results/gh-cli-readme-lint-results/gh-cli-readme-lint-results.txt"
98-
process_lint_results "🔧 ./scripts scripts" "./lint-results/scripts-readme-lint-results/scripts-readme-lint-results.txt"
99-
100-
echo "---" >> comment.md
101-
echo "*Lint results updated at $(date)*" >> comment.md
102-
103-
- name: Post Sticky PR Comment
104-
if: github.event_name == 'pull_request'
105-
uses: marocchino/sticky-pull-request-comment@v2
106-
with:
107-
header: readme-lint-results
108-
path: comment.md
60+
echo "## Lint Results for ./scripts/README.md" >> "$GITHUB_STEP_SUMMARY"
61+
echo "" >> "$GITHUB_STEP_SUMMARY"
62+
echo '```' >> "$GITHUB_STEP_SUMMARY"
63+
if [ -f lint-results.txt ]; then
64+
cat lint-results.txt >> "$GITHUB_STEP_SUMMARY"
65+
else
66+
echo "No results available" >> "$GITHUB_STEP_SUMMARY"
67+
fi
68+
echo '```' >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)