Skip to content

Commit c0fc25a

Browse files
committed
Attach docs metadata
1 parent 1fe53cd commit c0fc25a

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

.github/workflows/artifacts.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ permissions:
1313
jobs:
1414
notify:
1515
runs-on: ubuntu-latest
16-
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.pull_requests.length > 0 }}
16+
if: ${{ github.event.workflow_run.event == 'pull_request' }}
1717
steps:
1818
- uses: actions/github-script@v7
1919
with:
@@ -28,9 +28,20 @@ jobs:
2828
throw new Error('Expected one artifact')
2929
}
3030
31-
const pullNumber = context.payload.workflow_run.pull_requests[0].number;
32-
const artifactId = artifacts.data.artifacts[0].id;
33-
const artifactUrl = `${context.payload.workflow_run.html_url}/artifacts/${artifactId}`;
31+
const artifact = artifacts.data.artifacts[0];
32+
const download = await github.rest.actions.downloadArtifact({
33+
owner: context.repo.owner,
34+
repo: context.repo.repo,
35+
artifact_id: artifact.id,
36+
archive_format: 'zip'
37+
});
38+
39+
const zlib = require('zlib');
40+
const zip = zlib.unzipSync(Buffer.from(download.data));
41+
const ghInfo = JSON.parse(zip.toString());
42+
const pullNumber = ghInfo.number;
43+
44+
const artifactUrl = `${context.payload.workflow_run.html_url}/artifacts/${artifact.id}`;
3445
const commentBody = `<!-- build-artifact-comment -->\n📦 Docs artifacts are ready: ${artifactUrl}`;
3546
3647
const comments = await github.rest.issues.listComments({

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ jobs:
4141
- name: Generate docs
4242
run: test/prerelease.sh
4343

44+
- name: Attach docs metadata
45+
run: |
46+
echo "{\"pr_number\":${{ github.event.number }},\"artifact_id\":${{ steps.docs-upload.outputs.artifact-id }}}" > test/tmp/contents/doc/gh.json
47+
4448
- name: Upload docs
4549
uses: actions/upload-artifact@v4
4650
id: docs-upload

0 commit comments

Comments
 (0)