mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-26 18:38:41 +08:00
c05c429803
Co-authored-by: github-merge-queue <118344674+github-merge-queue@users.noreply.github.com> Co-authored-by: github-merge-queue <github-merge-queue@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Florian Duros <florian.duros@ormaz.fr> Co-authored-by: Kim Brose <kim.brose@nordeck.net> Co-authored-by: Florian Duros <florianduros@element.io> Co-authored-by: R Midhun Suresh <hi@midhun.dev> Co-authored-by: dbkr <986903+dbkr@users.noreply.github.com> Co-authored-by: ElementRobot <releases@riot.im> Co-authored-by: dbkr <dbkr@users.noreply.github.com> Co-authored-by: David Baker <dbkr@users.noreply.github.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Co-authored-by: David Langley <davidl@element.io> Co-authored-by: Michael Weimann <michaelw@matrix.org> Co-authored-by: Timshel <Timshel@users.noreply.github.com> Co-authored-by: Sahil Silare <32628578+sahil9001@users.noreply.github.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Hubert Chathi <hubert@uhoreg.ca> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> Co-authored-by: Robin <robin@robin.town> Co-authored-by: Tulir Asokan <tulir@maunium.net>
92 lines
4.6 KiB
YAML
92 lines
4.6 KiB
YAML
name: Pending reviews automation
|
|
on:
|
|
# The bot exceeded its API rate limit. Disabling for now (adding workflow dispatch so the workflow file stays valid & we can test to see if it starts working again)
|
|
workflow_dispatch: {}
|
|
# We run it on a schedule instead of on pull_request_* events to not create confusing messaging in the PR
|
|
#schedule:
|
|
# - cron: "*/10 * * * *"
|
|
concurrency: ${{ github.workflow }}
|
|
jobs:
|
|
bot:
|
|
name: Pending reviews bot
|
|
runs-on: ubuntu-latest
|
|
environment: Matrix
|
|
env:
|
|
URL: "https://github.com/pulls?q=is%3Apr+is%3Aopen+repo%3Amatrix-org%2Fmatrix-js-sdk+repo%3Amatrix-org%2Fmatrix-react-sdk+repo%3Aelement-hq%2Felement-web+repo%3Aelement-hq%2Felement-desktop+review-requested%3A%40me+sort%3Aupdated-desc+"
|
|
RELEASE_BLOCKERS_URL: "https://github.com/pulls?q=is%3Aopen+repo%3Amatrix-org%2Fmatrix-js-sdk+repo%3Amatrix-org%2Fmatrix-react-sdk+repo%3Aelement-hq%2Felement-web+repo%3Aelement-hq%2Felement-desktop+sort%3Aupdated-desc+label%3AX-Release-Blocker+"
|
|
steps:
|
|
- uses: actions/github-script@v7
|
|
env:
|
|
HS_URL: ${{ secrets.BETABOT_HS_URL }}
|
|
ROOM_ID: ${{ secrets.ROOM_ID }}
|
|
TOKEN: ${{ secrets.BETABOT_ACCESS_TOKEN }}
|
|
with:
|
|
# PAT needed as the GITHUB_TOKEN won't be able to see cross-references from other orgs (matrix-org)
|
|
github-token: ${{ secrets.ELEMENT_BOT_TOKEN }}
|
|
script: |
|
|
const { HS_URL, ROOM_ID, TOKEN, URL, RELEASE_BLOCKERS_URL } = process.env;
|
|
|
|
async function updateCounter(counter, link, severity, title, value, clearOnZero) {
|
|
const apiUrl = `${HS_URL}/_matrix/client/v3/rooms/${ROOM_ID}/state/re.jki.counter/${counter}`;
|
|
const headers = {
|
|
"Content-Type": "application/json",
|
|
"Authorization": `Bearer ${TOKEN}`,
|
|
};
|
|
const res = await fetch(apiUrl, {
|
|
method: "GET",
|
|
headers,
|
|
});
|
|
|
|
const data = await res.json();
|
|
|
|
if (data.value === issueCount) {
|
|
console.log("Pending review count already correct");
|
|
return;
|
|
}
|
|
|
|
let body = {};
|
|
if (issueCount || !clearOnZero) {
|
|
body = JSON.stringify({
|
|
link,
|
|
severity,
|
|
title,
|
|
value,
|
|
});
|
|
}
|
|
|
|
await fetch(apiUrl, {
|
|
method: "PUT",
|
|
body,
|
|
headers,
|
|
});
|
|
}
|
|
|
|
const repos = [
|
|
"element-hq/element-desktop",
|
|
"element-hq/element-web",
|
|
"matrix-org/matrix-js-sdk",
|
|
];
|
|
const teams = [
|
|
"matrix-org/element-web-team",
|
|
"matrix-org/element-web-reviewers",
|
|
"element-hq/element-web-team",
|
|
"element-hq/element-web-reviewers",
|
|
];
|
|
|
|
let issueCount = 0;
|
|
for (const team of teams) {
|
|
const org = team.split("/", 2)[0];
|
|
const reposInOrg = repos.filter(repo => repo.startsWith(org + "/"));
|
|
const { data } = await github.rest.search.issuesAndPullRequests({
|
|
q: `is:pr is:open review:required ${reposInOrg.map(r => `repo:${r}`).join(" ")} team-review-requested:${team}`,
|
|
});
|
|
issueCount += data.total_count;
|
|
}
|
|
await updateCounter("gh_reviews", URL, "warning", "Pending reviews", issueCount);
|
|
|
|
const { data } = await github.rest.search.issuesAndPullRequests({
|
|
q: `is:open ${repos.map(repo => `repo:${repo}`).join(" ")} label:X-Release-Blocker`,
|
|
});
|
|
const blockerCount = data.total_count;
|
|
await updateCounter("release_blockers", RELEASE_BLOCKERS_URL, "alert", "Release Blockers", blockerCount, true);
|