Skip to content

Commit cb981bb

Browse files
authored
Merge branch 'main' into add-content
2 parents a47f7a0 + d6aedf6 commit cb981bb

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.github/workflows/pull-request-completed.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ jobs:
1010
name: Pull Request - Completed
1111

1212
permissions:
13-
# Required to read logs of other workflow
14-
actions: read
1513
contents: read
1614
pull-requests: write
1715

@@ -26,6 +24,7 @@ jobs:
2624
with:
2725
# Must use "pattern" instead of "name" to avoid errors if artifact doesn't exist
2826
pattern: foo
27+
# Must specify token and repository, to pull from the base fork in fork PRs
2928
github-token: ${{ github.token }}
3029
repository: ${{ github.repository }}
3130
run-id: ${{ github.event.workflow_run.id }}

.github/workflows/scripts/pull-request-completed.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ module.exports = async ({ github, context, core }) => {
2727
const sha = payload.workflow_run.head_sha;
2828

2929
console.log(`Finding pull requests for '/${owner}/${repo}/${sha}'`);
30+
31+
// Must call this API, since 'payload.workflow_run.pull_requests' is empty for fork PRs
3032
const { data: pullRequests } =
3133
await github.rest.repos.listPullRequestsAssociatedWithCommit({
3234
owner: owner,

.github/workflows/scripts/pull-request.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,20 @@ const { env } = require("process");
1010
* @param {string?} label
1111
*/
1212
module.exports = async ({ github, context, core }, folder, label) => {
13+
console.log(JSON.stringify(context, null, 2));
14+
1315
const file = join(folder, "content.txt");
1416

17+
const payload = /** @type {import("@octokit/webhooks-types").PullRequestEvent} */ (context.payload);
18+
19+
const permissionLevel = await github.rest.repos.getCollaboratorPermissionLevel({
20+
owner: payload.repository.owner.login,
21+
repo: payload.repository.name,
22+
username: payload.pull_request.user.login,
23+
});
24+
25+
console.log(JSON.stringify(permissionLevel, null, 2));
26+
1527
try {
1628
const content = await readFile(file, { encoding: "utf8" });
1729
console.log(`File '${file}' exists. Content:\n${content}`);

0 commit comments

Comments
 (0)