Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

fix: e2e report comment issue_number (#697)

Bill Chengcb2b19456fbc
diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml
index b1c41eae..be18d993 100644
--- a/.github/workflows/quality.yml
+++ b/.github/workflows/quality.yml
@@ -111,3 +111,15 @@ jobs:
with:
name: report
path: apps/web/playwright-report/
+
+ - name: Save PR number
+ env:
+ PR_NUMBER: ${{ github.event.number }}
+ run: |
+ echo $PR_NUMBER > prNumber
+
+ - name: Upload prNumber
+ uses: actions/upload-artifact@v3
+ with:
+ name: prNumber
+ path: prNumber
diff --git a/.github/workflows/report.yml b/.github/workflows/report.yml
index 981a4820..34ca0f73 100644
--- a/.github/workflows/report.yml
+++ b/.github/workflows/report.yml
@@ -32,11 +32,24 @@ jobs:
archive_format: 'zip',
});
+ const prNumberArtifact = allArtifacts.data.artifacts.find((artifact) => {
+ return artifact.name == "prNumber"
+ });
+ const prNumber = await github.rest.actions.downloadArtifact({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ artifact_id: prNumberArtifact.id,
+ archive_format: 'zip',
+ });
+
const fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/report.zip`, Buffer.from(report.data));
+ fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/prNumber.zip`, Buffer.from(prNumber.data));
- name: Unzip artifacts
- run: unzip report.zip -d report
+ run: |
+ unzip report.zip -d report
+ unzip prNumber.zip
- name: Publish report
if: always()
@@ -55,10 +68,13 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
+ const fs = require('fs');
+ const issue_number = Number(fs.readFileSync('./prNumber'));
+
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
- issue_number: context.payload.workflow_run.pull_requests[0].number
+ issue_number: issue_number
});
const botComment = comments.find(comment => {
@@ -76,7 +92,7 @@ jobs:
});
} else {
github.rest.issues.createComment({
- issue_number: context.payload.workflow_run.pull_requests[0].number,
+ issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output