feat: Build invoice diff utility — compare two invoice states (#363) #55
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: Conflict Check | |
| on: | |
| pull_request: | |
| branches: [main] | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| check-conflicts: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Check for merge conflicts | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| let mergeable = null; | |
| let attempts = 0; | |
| // Poll until GitHub computes mergeability (can take a few seconds) | |
| while (mergeable === null && attempts < 10) { | |
| await new Promise(r => setTimeout(r, 3000)); | |
| const { data: pr } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number, | |
| }); | |
| mergeable = pr.mergeable; | |
| attempts++; | |
| } | |
| if (mergeable === false) { | |
| // Avoid posting duplicate comments | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const alreadyCommented = comments.some(c => | |
| c.body.includes('Merge Conflict Detected') && | |
| c.user.login === 'github-actions[bot]' | |
| ); | |
| if (!alreadyCommented) { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `⚠️ **Merge Conflict Detected**\n\nThis PR has conflicts with \`main\` that must be resolved before it can be merged.\n\n**Steps to fix:**\n\`\`\`bash\ngit checkout main\ngit pull origin main\ngit checkout your-branch\ngit merge main\n# resolve conflicts in your editor\ngit add .\ngit commit\ngit push\n\`\`\`\n\nIf you need help resolving the conflict, leave a comment and the maintainer will assist.\n\n---\n*🤖 Automated conflict check*` | |
| }); | |
| } | |
| } |