|
8 | 8 | - '*.md' |
9 | 9 |
|
10 | 10 | permissions: |
11 | | - contents: write |
| 11 | + contents: read |
12 | 12 | pull-requests: write |
13 | 13 |
|
14 | 14 | jobs: |
|
39 | 39 | - name: Lint |
40 | 40 | run: pnpm lint |
41 | 41 |
|
42 | | - - name: Install Sprites CLI |
43 | | - run: | |
44 | | - curl -fsSL https://sprites.dev/install.sh | bash |
45 | | - echo "$HOME/.local/bin" >> $GITHUB_PATH |
46 | | -
|
47 | | - - name: Setup Sprites auth |
48 | | - run: sprite auth setup --token "$SPRITES_TEST_TOKEN" |
49 | | - env: |
50 | | - SPRITES_TEST_TOKEN: ${{ secrets.SPRITES_TEST_TOKEN }} |
51 | | - |
52 | | - - name: Generate CLI Docs |
53 | | - run: pnpm generate:cli-docs |
54 | | - env: |
55 | | - SKIP_CLI_TESTS: 'true' |
56 | | - |
57 | | - - name: Commit generated CLI docs |
58 | | - run: | |
59 | | - git config user.name "github-actions[bot]" |
60 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
61 | | - git add src/content/docs/cli/commands.mdx |
62 | | - if git diff --cached --quiet; then |
63 | | - echo "No changes to CLI docs" |
64 | | - else |
65 | | - git commit -m "Update auto-generated CLI documentation" |
66 | | - git push |
67 | | - fi |
68 | | -
|
69 | 42 | - name: Build |
70 | 43 | run: pnpm build |
71 | 44 |
|
72 | | - - name: Comment CLI Test Results on PR |
73 | | - if: always() && github.event_name == 'pull_request' |
74 | | - uses: actions/github-script@v7 |
75 | | - with: |
76 | | - script: | |
77 | | - const fs = require('fs'); |
78 | | - const path = './cli-test-report.json'; |
79 | | -
|
80 | | - let body = '### CLI Documentation Generator\n\n'; |
81 | | -
|
82 | | - if (!fs.existsSync(path)) { |
83 | | - body += '⚠️ No test report found (tests may have been skipped)\n'; |
84 | | - } else { |
85 | | - const report = JSON.parse(fs.readFileSync(path, 'utf8')); |
86 | | -
|
87 | | - const allPassed = report.testsFailed === 0; |
88 | | - const emoji = allPassed ? '✅' : '❌'; |
89 | | -
|
90 | | - body += `| Metric | Value |\n`; |
91 | | - body += `|--------|-------|\n`; |
92 | | - body += `| CLI Version | \`${report.cliVersion}\` |\n`; |
93 | | - body += `| Commands Generated | ${report.commandsGenerated.length} |\n`; |
94 | | - body += `| Tests | ${emoji} ${report.testsPassed}/${report.testsRun} passed |\n`; |
95 | | -
|
96 | | - if (report.errors.length > 0) { |
97 | | - body += `\n<details><summary>❌ ${report.errors.length} Error(s)</summary>\n\n`; |
98 | | - for (const error of report.errors) { |
99 | | - body += `- **${error.command}** (${error.phase}): ${error.message}\n`; |
100 | | - } |
101 | | - body += `\n</details>\n`; |
102 | | - } |
103 | | -
|
104 | | - if (report.commandsGenerated.length > 0) { |
105 | | - body += `\n<details><summary>📚 Commands documented</summary>\n\n`; |
106 | | - body += report.commandsGenerated.map(c => `- \`${c}\``).join('\n'); |
107 | | - body += `\n</details>\n`; |
108 | | - } |
109 | | - } |
110 | | -
|
111 | | - const { data: comments } = await github.rest.issues.listComments({ |
112 | | - owner: context.repo.owner, |
113 | | - repo: context.repo.repo, |
114 | | - issue_number: context.issue.number, |
115 | | - }); |
116 | | - const existing = comments.find(c => c.body.includes('### CLI Documentation Generator')); |
117 | | -
|
118 | | - if (existing) { |
119 | | - await github.rest.issues.updateComment({ |
120 | | - owner: context.repo.owner, |
121 | | - repo: context.repo.repo, |
122 | | - comment_id: existing.id, |
123 | | - body, |
124 | | - }); |
125 | | - } else { |
126 | | - await github.rest.issues.createComment({ |
127 | | - owner: context.repo.owner, |
128 | | - repo: context.repo.repo, |
129 | | - issue_number: context.issue.number, |
130 | | - body, |
131 | | - }); |
132 | | - } |
133 | | -
|
134 | 45 | preview: |
135 | 46 | name: Preview Deployment |
136 | 47 | runs-on: ubuntu-latest |
|
0 commit comments