-
Notifications
You must be signed in to change notification settings - Fork 26
67 lines (58 loc) · 2.05 KB
/
generate-monthly-updates.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Generate Monthly Updates
on:
workflow_dispatch:
schedule:
- cron: '0 0 28 * *' # Run on the 28th of every month at midnight UTC
permissions:
pull-requests: write
contents: write
jobs:
generate-monthly-updates:
if: github.repository_owner == 'unjs'
name: Generate Monthly Updates
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- run: corepack enable
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- run: pnpm jiti scripts/releases-article.ts
- name: Commit
run: |
git config --local user.email $EMAIL
git config --local user.name $USERNAME
git checkout -b monthly-updates
git add .
git commit -m "content: create monthly updates"
git push -f origin monthly-updates
env:
EMAIL: ${{ secrets.EMAIL }}
USERNAME: ${{ secrets.USERNAME }}
- name: Create Pull Request
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:monthly-updates`,
})
if (pullRequests.length === 0) {
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'content: create monthly updates',
head: 'monthly-updates',
base: 'main',
body: `- [ ] format the article by creating paragraphs\n\nThis PR is automatically generated by a script._`,
labels: ['content'],
})
}