chore: check if client PR exists or not #6
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: Status Desktop Companion PR Check | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, edited] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| check-companion-pr: | |
| name: Check for Status Desktop companion PR | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check for companion PR | |
| id: check | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set +e | |
| output=$(./_assets/scripts/check-companion-pr.sh "${{ github.event.pull_request.number }}" "${{ github.event.pull_request.head.sha }}") | |
| exit_code=$? | |
| set -e | |
| echo "$output" | |
| while IFS='=' read -r key value; do | |
| echo "${key,,}=${value}" >> "$GITHUB_OUTPUT" | |
| done < <(echo "$output" | grep -E '^[A-Z_]+=') | |
| exit $exit_code | |
| - name: Post comment | |
| if: always() | |
| uses: actions/github-script@v7 | |
| env: | |
| OUTPUTS_JSON: ${{ toJSON(steps.check.outputs) }} | |
| with: | |
| script: | | |
| const outputs = JSON.parse(process.env.OUTPUTS_JSON); | |
| const prNumber = context.payload.pull_request.number; | |
| const headSha = context.payload.pull_request.head.sha; | |
| let body; | |
| if (outputs.reason === 'no_link_in_description') { | |
| body = [ | |
| '<!-- companion-pr-check -->', | |
| '## ⚠️ Companion PR Required', | |
| '', | |
| 'Add a link to your status-desktop PR in this PR\'s description.', | |
| '', | |
| 'Example: `https://github.com/status-im/status-desktop/pull/123`' | |
| ].join('\n'); | |
| } else if (outputs.reason === 'sha_mismatch') { | |
| body = [ | |
| '<!-- companion-pr-check -->', | |
| '## ⚠️ Companion PR Needs Update', | |
| '', | |
| '[#' + outputs.companion_pr_number + '](' + outputs.companion_pr_url + ') is not using the latest status-go commit (`' + headSha + '`).', | |
| '', | |
| 'Update `vendor/status-go` in the companion PR.' | |
| ].join('\n'); | |
| } else if (outputs.verified === 'true') { | |
| body = [ | |
| '<!-- companion-pr-check -->', | |
| '## ✅ Companion PR Verified', | |
| '', | |
| '[#' + outputs.companion_pr_number + ' - ' + outputs.companion_pr_title + '](' + outputs.companion_pr_url + ')' | |
| ].join('\n'); | |
| } else { | |
| return; | |
| } | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber | |
| }); | |
| const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes('<!-- companion-pr-check -->')); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body | |
| }); | |
| } |