Update JesperLundberg/projektgunnar.nvim
#912
Workflow file for this run
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: PR Compliance Check | |
| permissions: read-all | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| pull_request_review: | |
| types: | |
| - submitted | |
| jobs: | |
| compliance-check: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Check if PR is from fork | |
| id: fork-check | |
| run: | | |
| if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then | |
| echo "is_fork=true" >> $GITHUB_OUTPUT | |
| echo "_This PR is from a fork - compliance check will run with limited permissions._" | |
| else | |
| echo "is_fork=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Run PR compliance check | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| echo -e "## π PR Compliance Check Results:\n" >> compliance_report.md | |
| PR_NUMBER="${{ github.event.pull_request.number }}" | |
| IS_FORK="${{ steps.fork-check.outputs.is_fork }}" | |
| if [ "$IS_FORK" = "true" ]; then | |
| echo -e "**Source**: π External fork contribution.\n" >> compliance_report.md | |
| fi | |
| # Run compliance check for this PR | |
| if [ -f "./scripts/batch_pr_compliance.sh" ] && [ -x "./scripts/batch_pr_compliance.sh" ]; then | |
| ./scripts/batch_pr_compliance.sh "$PR_NUMBER" > compliance_output.txt 2>&1 | |
| # Parse results for this PR | |
| if grep -q "β PR $PR_NUMBER: Compliant" compliance_output.txt; then | |
| echo "β **Status**: Compliant - All requirements met!" >> compliance_report.md | |
| elif grep -q "β" compliance_output.txt; then | |
| echo -e "β **Status**: Non-Compliant - Issues found that need fixing.\n" >> compliance_report.md | |
| echo -e "### Issues Found:\n" >> compliance_report.md | |
| grep "β PR $PR_NUMBER:" compliance_output.txt | sed 's/β PR [0-9]*: /- /' >> compliance_report.md | |
| fi | |
| echo "" >> compliance_report.md | |
| # Review status information | |
| if grep -q "π¨\|β \|βΉοΈ" compliance_output.txt; then | |
| echo "### Review Status:" >> compliance_report.md | |
| grep -E "(π¨|β |βΉοΈ) PR $PR_NUMBER:" compliance_output.txt | sed "s/PR $PR_NUMBER: //" >> compliance_report.md | |
| echo "" >> compliance_report.md | |
| fi | |
| else | |
| echo -e "β οΈ **Status**: Compliance script not found - manual review required.\n" >> compliance_report.md | |
| fi | |
| # Add helpful guidance | |
| if grep -q "β" compliance_output.txt 2>/dev/null; then | |
| echo -e "### Quick Fix Guide:\n" >> compliance_report.md | |
| echo "- **Title Format**: Use \`\`\` <Add|Update|Remove> \`username/repo\` \`\`\`." >> compliance_report.md | |
| echo "- **Description**: Remove 'plugin' word, end with period." >> compliance_report.md | |
| echo -e "- **Repository**: Ensure public repo with README and license.\n" >> compliance_report.md | |
| echo "_After fixing issues, push new commits to update this check._" >> compliance_report.md | |
| else | |
| echo -e "### Next Steps:\n" >> compliance_report.md | |
| if [ "$IS_FORK" = "true" ]; then | |
| echo "β Thank you for your contribution!" >> compliance_report.md | |
| echo "π Ready for maintainer review." >> compliance_report.md | |
| else | |
| echo "β Ready for manual review by maintainers." >> compliance_report.md | |
| echo "π Repository quality will be analyzed automatically." >> compliance_report.md | |
| fi | |
| fi | |
| echo -e "\n---\n" "_Automated check powered by [enhanced PR review scripts](scripts/)._" >> compliance_report.md | |
| - name: Post compliance results as comment (non-fork only) | |
| if: steps.fork-check.outputs.is_fork == 'false' | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const report = fs.readFileSync('compliance_report.md', 'utf8'); | |
| const prNumber = ${{ github.event.pull_request.number }}; | |
| try { | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| }); | |
| const existingComment = comments.find(comment => | |
| comment.body.includes('π PR Compliance Check Results') && | |
| (comment.user.type === 'Bot' || comment.user.login === 'github-actions[bot]') | |
| ); | |
| if (existingComment) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existingComment.id, | |
| body: report | |
| }); | |
| console.log(`β Updated compliance comment on PR #${prNumber}`); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: report | |
| }); | |
| console.log(`β Posted compliance comment on PR #${prNumber}`); | |
| } | |
| } catch (error) { | |
| console.error(`β Failed to post compliance comment: ${error.message}`); | |
| core.setFailed(`Failed to post comment: ${error.message}`); | |
| } | |
| - name: Output compliance report for fork PRs | |
| if: steps.fork-check.outputs.is_fork == 'true' | |
| run: | | |
| echo -e "Fork PR detected - compliance report saved as workflow output.\n" "$(cat compliance_report.md)\n" | |
| echo "β οΈ Maintainers: Review the compliance report above for this fork PR." |