Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(github): popular-prs workflow #70414

Merged
merged 4 commits into from
Sep 24, 2024
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
16 changes: 16 additions & 0 deletions .github/actions/next-repo-actions/dist/prs/index.js

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions .github/actions/next-repo-actions/dist/prs/index.mjs

This file was deleted.

74 changes: 74 additions & 0 deletions .github/actions/next-repo-actions/dist/prs/licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,30 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


debug
MIT
(The MIT License)

Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
Copyright (c) 2018-2021 Josh Junon

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the 'Software'), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



delayed-stream
MIT
Copyright (c) 2011 Debuggable Limited <felix@debuggable.com>
Expand Down Expand Up @@ -800,6 +824,31 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


ms
MIT
The MIT License (MIT)

Copyright (c) 2016 Zeit, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


nextjs-project
The MIT License (MIT)

Expand Down Expand Up @@ -956,6 +1005,31 @@ Felix Geisendörfer (felix@debuggable.com)
THE SOFTWARE.


slack-block-builder
MIT
MIT License

Copyright (c) 2020 Ray East

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


tunnel
MIT
The MIT License (MIT)
Expand Down
10 changes: 5 additions & 5 deletions .github/actions/next-repo-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"build": "pnpm build-issues-by-version && pnpm build-issues && pnpm build-prs && pnpm build-feature-requests && pnpm build-bankrupt-issues && pnpm build-triage-issues-with-ai",
"build-issues-by-version": "ncc build src/issues-by-version.ts -m -o dist/issues-by-version --license licenses.txt",
"build-issues": "ncc build src/popular-issues.mjs -m -o dist/issues --license licenses.txt",
"build-prs": "ncc build src/popular-prs.mjs -m -o dist/prs --license licenses.txt",
"build-prs": "ncc build src/popular-prs.ts -m -o dist/prs --license licenses.txt",
"build-feature-requests": "ncc build src/popular-feature-requests.mjs -m -o dist/feature-requests --license licenses.txt",
"build-bankrupt-issues": "ncc build src/bankrupt-issues.ts -m -o dist/bankrupt --license licenses.txt",
"build-triage-issues-with-ai": "ncc build src/triage-issues-with-ai.ts -m -o dist/triage-issues-with-ai --license licenses.txt"
Expand All @@ -14,13 +14,13 @@
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1",
"@actions/github": "6.0.0",
"@ai-sdk/openai": "^0.0.55",
"@slack/web-api": "^7.3.4",
"ai": "^3.3.26",
"@ai-sdk/openai": "^0.0.62",
"@slack/web-api": "^7.5.0",
"ai": "^3.4.2",
"slack-block-builder": "^2.8.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@vercel/ncc": "^0.38.1"
"@vercel/ncc": "^0.38.2"
}
}
78 changes: 0 additions & 78 deletions .github/actions/next-repo-actions/src/popular-prs.mjs

This file was deleted.

66 changes: 66 additions & 0 deletions .github/actions/next-repo-actions/src/popular-prs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// @ts-check
import { setFailed, info } from '@actions/core'
import { context, getOctokit } from '@actions/github'
import { WebClient } from '@slack/web-api'
import { BlockCollection, Divider, Section } from 'slack-block-builder'
import { formattedDate, ninetyDaysAgo } from '../lib/util.mjs'

async function run() {
try {
if (!process.env.GITHUB_TOKEN) throw new TypeError('GITHUB_TOKEN not set')
if (!process.env.SLACK_TOKEN) throw new TypeError('SLACK_TOKEN not set')

const octoClient = getOctokit(process.env.GITHUB_TOKEN)
const slackClient = new WebClient(process.env.SLACK_TOKEN)

const { owner, repo } = context.repo

const { data: prs } = await octoClient.rest.search.issuesAndPullRequests({
order: 'desc',
per_page: 15,
q: `repo:${owner}/${repo} -is:draft is:pr is:open created:>=${ninetyDaysAgo()}`,
sort: 'reactions',
})

if (prs.items.length > 0) {
let text = ''
let count = 0

prs.items.forEach((pr, i) => {
if (pr.reactions) {
if (pr.reactions.total_count > 1) {
text += `${i + 1}. [<${pr.html_url}|#${pr.number}>, ${
pr.reactions.total_count
} reactions, ${formattedDate(pr.created_at)}]: ${pr.title}\n`
count++
}
}
})

const blocks = BlockCollection([
Section({
text: `*A list of the top ${count} PRs sorted by the most reactions (> 1) over the last 90 days.*\n_Note: This :github2: <https://github.com/vercel/next.js/blob/canary/.github/workflows/popular.yml|workflow> → <https://github.com/vercel/next.js/blob/canary/.github/actions/next-repo-info/src/popular-prs.mjs|action> will run every Monday at 10AM UTC (6AM EST)._`,
}),
Divider(),
Section({
text,
}),
])

await slackClient.chat.postMessage({
blocks,
channel: '#next-info',
icon_emoji: ':github:',
username: 'GitHub Notifier',
})

info(`Posted to Slack!`)
} else {
info(`No popular PRs.`)
}
} catch (error) {
setFailed(error)
}
}

run()
Loading
Loading