Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/scripts/pr-updated.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { IDENTIFIER, PACKAGE_NAME } from "./params.mjs"
import github from "@actions/github"

const octokit = new Octokit({})
const prNumber = github.context.payload.pull_request.number
const prNumber =
github.context.payload.pull_request?.number ||
Number(process.env.PR_NUMBER)

async function createOrUpdateComment(prevComment, prNumber, body) {
if (prevComment) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: PR Updated
name: PR Build

on:
pull_request_target:
pull_request:
branches:
- next

Expand All @@ -10,19 +10,13 @@ concurrency:
cancel-in-progress: true

jobs:
comment-pr:
name: Comment PR
build:
name: Build PR
runs-on: ubuntu-latest

permissions:
issues: write
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: "${{ github.event.pull_request.head.sha }}"

- name: Install pnpm
uses: pnpm/action-setup@v4
Expand All @@ -41,7 +35,8 @@ jobs:

- run: pnpm canary

- name: Add or update PR comment
run: node .github/scripts/pr-updated.mjs ${{ github.event.pull_request.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: pr-build
path: canary.json
50 changes: 50 additions & 0 deletions .github/workflows/pr-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: PR Comment

on:
workflow_run:
workflows: ["PR Build"]
types:
- completed

jobs:
comment-pr:
name: Comment PR
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'

permissions:
contents: read
actions: read
issues: write
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: pr-build
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- name: Install script dependencies
run: pnpm install --ignore-scripts

- name: Add or update PR comment
run: node .github/scripts/pr-updated.mjs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
Loading