Skip to content

Write Pre-Release Comment #21

Write Pre-Release Comment

Write Pre-Release Comment #21

name: Write Pre-Release Comment
# Adapted from the following workflow:
# https://github.com/cloudflare/next-on-pages/blob/main/.github/workflows/write-prerelease-comment.yml
on:
workflow_run:
workflows: [Pre-Release]
types:
- completed
jobs:
comment:
name: Comment on PR
if: ${{ github.repository_owner == 'james-elicx' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Put PR and workflow ID into env
uses: actions/github-script@v7
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-build-output-router-(\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
uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ env.WORKFLOW_RUN_PR }}
message: |
🧪 A prerelease is available for testing 🧪
<details>
You can install this latest build in your project with:
```sh
npm i https://prerelease-registry.ixion-labs.workers.dev/james-elicx/build-output-router/runs/${{ env.WORKFLOW_RUN_ID }}/npm-package-build-output-router-${{ env.WORKFLOW_RUN_PR }}
```
</details>