Skip to content

Commit

Permalink
Add website PR creation script
Browse files Browse the repository at this point in the history
  • Loading branch information
pomber committed Sep 12, 2024
1 parent 93fb3ae commit d4bd878
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/scripts/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ For every push to `next`:
- labels: `release`
```

```
- create a PR from 'next' to 'main' if it doesn't exist
- title: Update website
```

## release-pr-merged

for every `release` pr merged to `next`:
Expand Down
37 changes: 37 additions & 0 deletions .github/scripts/website-pr.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Octokit } from "@octokit/action"
import github from "@actions/github"
import { BASE_BRANCH } from "./params.mjs"

const octokit = new Octokit({})

console.log("Find existing PR")
const { data: prs } = await octokit.pulls.list({
...github.context.repo,
state: "open",
base: "main",
head: `${github.context.repo.owner}:${BASE_BRANCH}`,
})
console.log("Existing PRs", prs)

const title = `✨ Update website ✨`
const body = ""

if (prs.length === 0) {
console.log("Creating new PR")
await octokit.rest.pulls.create({
...github.context.repo,
base: "main",
head: BASE_BRANCH,
title,
body,
})
} else {
// console.log("Updating existing PR")
// const { number } = prs[0]
// await octokit.rest.pulls.update({
// ...github.context.repo,
// pull_number: number,
// title,
// body,
// })
}
29 changes: 29 additions & 0 deletions .github/workflows/push-to-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,32 @@ jobs:
run: node .github/scripts/prepare-release.mjs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

website-pr:
name: Update website PR
runs-on: ubuntu-latest

permissions:
pull-requests: write

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

- 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"

- run: pnpm install

- name: Create or update website PR
run: node .github/scripts/website-pr.mjs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit d4bd878

Please sign in to comment.