Skip to content

Commit 92c7675

Browse files
committed
ci: posting results of linting as sticky PR comment
1 parent 72d2953 commit 92c7675

File tree

1 file changed

+70
-2
lines changed

1 file changed

+70
-2
lines changed

.github/workflows/lint-readme.yml

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ jobs:
2020
uses: actions/checkout@v4
2121

2222
- name: Lint ./gh-cli/README.md
23-
run: node ./.github/scripts/lint-readme.js
23+
id: lint
24+
run: node ./.github/scripts/lint-readme.js | tee gh-cli-readme-lint-results.txt
25+
26+
- name: Upload lint results
27+
if: steps.lint.outcome == 'failure' || steps.lint.outcome == 'success'
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: gh-cli-readme-lint-results
31+
path: gh-cli-readme-lint-results.txt
2432

2533
lint-scripts-readme:
2634
name: Lint ./scripts/README.md
@@ -33,4 +41,64 @@ jobs:
3341
uses: actions/checkout@v4
3442

3543
- name: Lint ./scripts/README.md
36-
run: node ./.github/scripts/lint-readme.js ./scripts '##' '# scripts'
44+
id: lint
45+
run: node ./.github/scripts/lint-readme.js ./scripts '##' '# scripts' | tee scripts-readme-lint-results.txt
46+
47+
- name: Upload lint results
48+
if: steps.lint.outcome == 'failure' || steps.lint.outcome == 'success'
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: scripts-readme-lint-results
52+
path: scripts-readme-lint-results.txt
53+
54+
post-results:
55+
name: Post Lint Results as PR Comment
56+
runs-on: ubuntu-latest
57+
if: always()
58+
needs:
59+
- lint-gh-cli-readme
60+
- lint-scripts-readme
61+
permissions:
62+
pull-requests: write
63+
64+
steps:
65+
- name: Download lint results
66+
uses: actions/download-artifact@v5
67+
with:
68+
path: ./lint-results/
69+
70+
- name: Process Lint Results
71+
id: process-results
72+
run: |
73+
echo "## 📋 README Lint Results" > comment.md
74+
echo "" >> comment.md
75+
76+
# Function to process lint results
77+
process_lint_results() {
78+
local title="$1"
79+
local file="$2"
80+
81+
echo "### $title" >> comment.md
82+
echo "\`\`\`" >> comment.md
83+
if [ -f "$file" ]; then
84+
cat "$file" >> comment.md
85+
else
86+
echo "❌ No results available" >> comment.md
87+
fi
88+
echo "\`\`\`" >> comment.md
89+
echo "" >> comment.md
90+
}
91+
92+
# Process both README results
93+
process_lint_results "🚀 gh-cli/README.md" "./lint-results/gh-cli-readme-lint-results/gh-cli-readme-lint-results.txt"
94+
process_lint_results "🔧 scripts/README.md" "./lint-results/scripts-readme-lint-results/scripts-readme-lint-results.txt"
95+
96+
echo "---" >> comment.md
97+
echo "*Lint results updated at $(date)*" >> comment.md
98+
99+
- name: Post Sticky PR Comment
100+
if: github.event_name == 'pull_request'
101+
uses: marocchino/sticky-pull-request-comment@v2
102+
with:
103+
header: readme-lint-results
104+
path: comment.md

0 commit comments

Comments
 (0)