Skip to content

Write prerelease comment #2

Write prerelease comment

Write prerelease comment #2

name: Write prerelease comment
on:
workflow_run:
workflows: ["Create Pull Request Prerelease"]
types:
- completed
jobs:
comment:
if: ${{ github.repository_owner == 'cloudflare' }}
runs-on: ubuntu-latest
name: Write comment to the PR
steps:
- name: "Put PR and workflow ID on the environment"
uses: actions/github-script@v5
with:
script: |
const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
for (const artifact of allArtifacts.data.artifacts) {
// Extract the PR number from the artifact name
const match = /^npm-package-wrangler-(\d+)$/.exec(artifact.name);
if (match) {
require("fs").appendFileSync(
process.env.GITHUB_ENV,
`\nWORKFLOW_RUN_PR=${match[1]}` +
`\nWORKFLOW_RUN_ID=${context.payload.workflow_run.id}`
);
break;
}
}
- name: "Comment on PR with Link"
uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ env.WORKFLOW_RUN_PR }}
message: |
A wrangler prerelease is available for testing. You can install this latest build in your project with:
```sh
npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/${{ env.WORKFLOW_RUN_ID }}/npm-package-wrangler-${{ env.WORKFLOW_RUN_PR }}
```
You can reference the automatically updated head of this PR with:
```sh
npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/${{ env.WORKFLOW_RUN_PR }}/npm-package-wrangler-${{ env.WORKFLOW_RUN_PR }}
```
Or you can use `npx` with this latest build directly:
```sh
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/${{ env.WORKFLOW_RUN_ID }}/npm-package-wrangler-${{ env.WORKFLOW_RUN_PR }} dev path/to/script.js
```
<details><summary>Additional artifacts:</summary>
```sh
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/${{ env.WORKFLOW_RUN_ID }}/npm-package-cloudflare-pages-shared-${{ env.WORKFLOW_RUN_PR }}
```
Note that these links will no longer work once [the GitHub Actions artifact expires](https://docs.github.com/en/organizations/managing-organization-settings/configuring-the-retention-period-for-github-actions-artifacts-and-logs-in-your-organization).