Repository navigation
feat: added swipe card #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: README Update Check | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, ready_for_review] | ||
| permissions: | ||
| pull-requests: write | ||
| contents: read | ||
| jobs: | ||
| check-readme: | ||
| name: Check README is updated | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check README update | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const { data: files } = await github.rest.pulls.listFiles({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: context.issue.number, | ||
| per_page: 100 | ||
| }); | ||
| // Was README updated? | ||
| const readmeUpdated = files.some(f => f.filename === 'README.md'); | ||
| // PR stats | ||
| const totalAdditions = files.reduce((sum, f) => sum + f.additions, 0); | ||
| const fileCount = files.length; | ||
| // New screen/component files added | ||
| const newScreenFiles = files.filter(f => | ||
| f.status === 'added' && | ||
| (f.filename.startsWith('app/') || f.filename.startsWith('src/') || f.filename.startsWith('components/')) && | ||
| (f.filename.endsWith('.tsx') || f.filename.endsWith('.ts')) | ||
| ); | ||
| // Large PR criteria: more than 10 files, 300+ lines added, or new screen files | ||
| const isLargePR = fileCount > 10 || totalAdditions > 300 || newScreenFiles.length > 0; | ||
| const BOT_MARKER = '<!-- readme-check-bot -->'; | ||
| // Find existing bot comment | ||
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number | ||
| }); | ||
| const existingComment = comments.find(c => c.body.includes(BOT_MARKER)); | ||
| if (isLargePR && !readmeUpdated) { | ||
| const newScreenList = newScreenFiles.length > 0 | ||
| ? '\n**Newly added files:**\n' + newScreenFiles.map(f => ` - \`${f.filename}\``).join('\n') | ||
| : ''; | ||
| const body = `${BOT_MARKER} | ||
| ## ⚠️ README Not Updated | ||
| This PR contains significant changes but \`README.md\` has not been updated. | ||
| **PR Stats:** | ||
| - Files changed: **${fileCount}** | ||
| - Lines added: **${totalAdditions}** | ||
| ${newScreenList} | ||
| **Please update \`README.md\` to cover:** | ||
| - [ ] Description of new screens / features added | ||
| - [ ] Navigation changes (if any) | ||
| - [ ] Setup or usage changes (if any) | ||
| This warning will be automatically resolved once README is updated.`; | ||
| if (existingComment) { | ||
| await github.rest.issues.updateComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| comment_id: existingComment.id, | ||
| body | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| body | ||
| }); | ||
| } | ||
| core.setFailed('README.md was not updated. Please include a README change in this PR.'); | ||
| } else { | ||
| // If there was a previous warning comment, mark it as resolved | ||
| if (existingComment) { | ||
| await github.rest.issues.updateComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| comment_id: existingComment.id, | ||
| body: `${BOT_MARKER}\n## ✅ README Updated\n\nThanks! \`README.md\` has been updated. Check passed.` | ||
| }); | ||
| } | ||
| console.log('README is up to date or PR is small. Check passed.'); | ||
| } | ||