3636 name : Test supabase-js with preview dependency
3737 runs-on : ubuntu-latest
3838 steps :
39+ - name : Generate GitHub App token
40+ id : generate-token
41+ uses : actions/create-github-app-token@v1
42+ with :
43+ app-id : ${{ vars.CROSS_REPO_APP_ID }}
44+ private-key : ${{ secrets.CROSS_REPO_APP_PRIVATE_KEY }}
45+ owner : supabase
46+ repositories : ${{ inputs.triggering_repo }}
47+
48+ - name : Post initial comment
49+ uses : actions/github-script@v7
50+ with :
51+ github-token : ${{ steps.generate-token.outputs.token }}
52+ script : |
53+ // Unique identifier for this bot's comments
54+ const commentIdentifier = '<!-- supabase-js-test-results -->';
55+
56+ const body = `${commentIdentifier}
57+ ## 🔄 supabase-js CI Tests Running...
58+
59+ **Status:** Tests in progress
60+
61+ Tests triggered by preview release of \`${{ inputs.package_name }}\`
62+
63+ | Test Suite | Status |
64+ |------------|--------|
65+ | Type Check | ⏳ Running... |
66+ | Unit Tests | ⏳ Pending... |
67+ | Integration Tests | ⏳ Pending... |
68+
69+ **Preview Package:** \`${{ inputs.preview_url }}\`
70+ **Commit:** [\`${{ inputs.triggering_sha }}\`](https://github.com/supabase/${{ inputs.triggering_repo }}/commit/${{ inputs.triggering_sha }})
71+
72+ [View workflow run](https://github.com/supabase/supabase-js/actions/runs/${{ github.run_id }})
73+
74+ _This comment will update when tests complete._`;
75+
76+ try {
77+ // First, try to find an existing comment from this bot
78+ const { data: comments } = await github.rest.issues.listComments({
79+ owner: 'supabase',
80+ repo: '${{ inputs.triggering_repo }}',
81+ issue_number: parseInt('${{ inputs.triggering_pr }}')
82+ });
83+
84+ // Look for a comment with our identifier
85+ const botComment = comments.find(comment =>
86+ comment.body && comment.body.includes(commentIdentifier)
87+ );
88+
89+ if (botComment) {
90+ // Update existing comment
91+ await github.rest.issues.updateComment({
92+ owner: 'supabase',
93+ repo: '${{ inputs.triggering_repo }}',
94+ comment_id: botComment.id,
95+ body: body
96+ });
97+ console.log('Successfully updated existing comment with running status');
98+ } else {
99+ // Create new comment if none exists
100+ await github.rest.issues.createComment({
101+ owner: 'supabase',
102+ repo: '${{ inputs.triggering_repo }}',
103+ issue_number: parseInt('${{ inputs.triggering_pr }}'),
104+ body: body
105+ });
106+ console.log('Successfully posted new comment with running status');
107+ }
108+ } catch (error) {
109+ console.log('Failed to post/update initial comment:', error.message);
110+ }
111+
39112 - name : Checkout supabase-js
40113 uses : actions/checkout@v4
41114
@@ -94,22 +167,6 @@ jobs:
94167 else
95168 echo "result=failure" >> $GITHUB_OUTPUT
96169 fi
97- - name : Generate GitHub App token
98- id : generate-token
99- uses : actions/create-github-app-token@v1
100- with :
101- app-id : ${{ vars.CROSS_REPO_APP_ID }}
102- private-key : ${{ secrets.CROSS_REPO_APP_PRIVATE_KEY }}
103- owner : supabase
104- # Generate token specifically for the repo we need to comment on
105- repositories : ${{ inputs.triggering_repo }}
106-
107- - name : Debug token permissions
108- run : |
109- echo "Token generated successfully"
110- echo "App ID: ${{ vars.CROSS_REPO_APP_ID }}"
111- echo "Target repositories: realtime-js,supabase-js"
112- echo "Attempting to comment on: supabase/realtime-js#${{ inputs.triggering_pr }}"
113170 - name : Stop Supabase
114171 if : always()
115172 run : supabase stop
@@ -128,8 +185,10 @@ jobs:
128185 integrationTestResult === 'success';
129186 const statusIcon = allPassed ? '✅' : '❌';
130187 const overallStatus = allPassed ? 'PASSED' : 'FAILED';
131- // Unique identifier for this bot's comments
188+
189+ // Unique identifier for this bot's comments (using HTML comment for cleaner look)
132190 const commentIdentifier = '<!-- supabase-js-test-results -->';
191+
133192 const body = `${commentIdentifier}
134193 ## ${statusIcon} supabase-js CI Test Results
135194 **Overall Status: ${overallStatus}**
@@ -146,7 +205,7 @@ jobs:
146205 '⚠️ Some tests failed. Please review the failing tests before merging.'}
147206 <details>
148207 <summary>View workflow run</summary>
149- [View full test results](https://github.com/supabase/supabase-js/actions/runs/${context.runId })
208+ [View full test results](https://github.com/supabase/supabase-js/actions/runs/${{ github.run_id } })
150209 </details>`;
151210 try {
152211 // First, try to find an existing comment from this bot
0 commit comments