Skip to content

Commit

Permalink
Attach docs metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jan 3, 2025
1 parent 1fe53cd commit c0fc25a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
jobs:
notify:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.pull_requests.length > 0 }}
if: ${{ github.event.workflow_run.event == 'pull_request' }}
steps:
- uses: actions/github-script@v7
with:
Expand All @@ -28,9 +28,20 @@ jobs:
throw new Error('Expected one artifact')
}
const pullNumber = context.payload.workflow_run.pull_requests[0].number;
const artifactId = artifacts.data.artifacts[0].id;
const artifactUrl = `${context.payload.workflow_run.html_url}/artifacts/${artifactId}`;
const artifact = artifacts.data.artifacts[0];
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip'
});
const zlib = require('zlib');
const zip = zlib.unzipSync(Buffer.from(download.data));
const ghInfo = JSON.parse(zip.toString());
const pullNumber = ghInfo.number;
const artifactUrl = `${context.payload.workflow_run.html_url}/artifacts/${artifact.id}`;
const commentBody = `<!-- build-artifact-comment -->\n📦 Docs artifacts are ready: ${artifactUrl}`;
const comments = await github.rest.issues.listComments({
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
- name: Generate docs
run: test/prerelease.sh

- name: Attach docs metadata
run: |
echo "{\"pr_number\":${{ github.event.number }},\"artifact_id\":${{ steps.docs-upload.outputs.artifact-id }}}" > test/tmp/contents/doc/gh.json
- name: Upload docs
uses: actions/upload-artifact@v4
id: docs-upload
Expand Down

0 comments on commit c0fc25a

Please sign in to comment.