feat: AquaPrime voice RPG + wallet ability (server-side rewrite) #1035
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: Branch Merge Check | |
| on: | |
| pull_request_target: | |
| branches: [dev, main] | |
| jobs: | |
| branch-check: | |
| name: branch-check | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| if: > | |
| github.event.pull_request.author_association != 'MEMBER' && | |
| github.event.pull_request.author_association != 'OWNER' | |
| steps: | |
| - name: Validate branch merge direction | |
| id: check | |
| run: | | |
| HEAD="${{ github.head_ref }}" | |
| BASE="${{ github.base_ref }}" | |
| echo "head=$HEAD" >> $GITHUB_OUTPUT | |
| echo "base=$BASE" >> $GITHUB_OUTPUT | |
| # Rule 1: Must target dev | |
| if [ "$BASE" != "dev" ]; then | |
| echo "status=fail" >> $GITHUB_OUTPUT | |
| echo "reason=Community PRs must target 'dev', not '$BASE'. Close this PR and re-open against 'dev'." >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Rule 2: Source cannot be dev or main | |
| if [ "$HEAD" = "dev" ] || [ "$HEAD" = "main" ]; then | |
| echo "status=fail" >> $GITHUB_OUTPUT | |
| echo "reason=Cannot merge '$HEAD' into '$BASE'. Use your feature branch (e.g. slow-music → dev)." >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo "status=pass" >> $GITHUB_OUTPUT | |
| echo "reason=" >> $GITHUB_OUTPUT | |
| - name: Comment on PR | |
| if: always() && steps.check.outcome == 'success' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const status = '${{ steps.check.outputs.status }}'; | |
| const reason = `${{ steps.check.outputs.reason }}`; | |
| const head = '${{ steps.check.outputs.head }}'; | |
| const base = '${{ steps.check.outputs.base }}'; | |
| let body = '<!-- branch-check-result -->\n'; | |
| body += '## 🔀 Branch Merge Check\n\n'; | |
| body += `**PR direction:** \`${head}\` → \`${base}\`\n\n`; | |
| if (status === 'pass') { | |
| body += `✅ **Passed** — \`${head}\` → \`${base}\` is a valid merge direction\n`; | |
| } else { | |
| body += '❌ **Failed** — ' + reason + '\n\n'; | |
| body += '**Allowed for community contributors:**\n'; | |
| body += '```\nyour-ability-branch → dev ✅\n```\n\n'; | |
| body += '**Blocked patterns:**\n'; | |
| body += '```\nanything → main ❌\n'; | |
| body += 'dev → dev ❌\n'; | |
| body += 'main → dev ❌\n```\n\n'; | |
| body += '> Close this PR and re-open it with the correct branch direction.'; | |
| } | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number | |
| }); | |
| const existing = comments.find(c => | |
| c.user.type === 'Bot' && c.body.includes('<!-- branch-check-result -->') | |
| ); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body: body | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: body | |
| }); | |
| } | |
| - name: Fail if invalid | |
| if: steps.check.outputs.status == 'fail' | |
| run: | | |
| echo "❌ ${{ steps.check.outputs.reason }}" | |
| exit 1 | |
| branch-check-member: | |
| name: branch-check | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event.pull_request.author_association == 'MEMBER' || | |
| github.event.pull_request.author_association == 'OWNER' | |
| steps: | |
| - run: echo "✅ Org member — all branch merges allowed" |