mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-09 20:44:03 -08:00
c88c4eb049
Bumps [actions/github-script](https://github.com/actions/github-script) from 6.3.0 to 6.3.1.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](d4560e1570...7dff1a8764
)
---
updated-dependencies:
- dependency-name: actions/github-script
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
65 lines
2.4 KiB
YAML
65 lines
2.4 KiB
YAML
name: Notify When Maintainers Cannot Edit
|
|
|
|
# **What it does**: Notifies the author of a PR when their PR does not allow maintainers to edit it.
|
|
# **Why we have it**: To prevent having to do this manually.
|
|
# **Who does it impact**: Open-source.
|
|
|
|
on:
|
|
pull_request_target:
|
|
types:
|
|
- opened
|
|
|
|
permissions:
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
notify-when-maintainers-cannot-edit:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/github-script@7dff1a87643417cf3b95bb10b29f4c4bc60d8ebd
|
|
with:
|
|
github-token: ${{ secrets.GH_PAT }}
|
|
script: |
|
|
const query = `
|
|
query($number: Int!) {
|
|
repository(owner: "JanDeDobbeleer", name: "oh-my-posh") {
|
|
pullRequest(number: $number) {
|
|
headRepositoryOwner {
|
|
login
|
|
}
|
|
maintainerCanModify
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
const pullNumber = context.issue.number;
|
|
const variables = { number: pullNumber };
|
|
|
|
try {
|
|
console.log(`Check JanDeDobbeleer/oh-my-posh#${pullNumber} for maintainer edit access ...`);
|
|
const result = await github.graphql(query, variables);
|
|
|
|
console.log(JSON.stringify(result, null, 2));
|
|
|
|
const pullRequest = result.repository.pullRequest;
|
|
|
|
if (pullRequest.headRepositoryOwner.login === 'JanDeDobbeleer') {
|
|
console.log('PR owned by JanDeDobbeleer');
|
|
return;
|
|
}
|
|
|
|
if (!pullRequest.maintainerCanModify) {
|
|
console.log('PR not owned by JanDeDobbeleer and does not have maintainer edits enabled');
|
|
|
|
await github.rest.issues.createComment({
|
|
issue_number: pullNumber,
|
|
owner: 'JanDeDobbeleer',
|
|
repo: 'oh-my-posh',
|
|
body: "Thanks for submitting a PR to the Oh My Posh project!\n\nIn order to review and merge PRs most efficiently, we require that all PRs grant maintainer edit access before we review them. For information on how to do this, [see the documentation](https://docs.github.com/en/github/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)."
|
|
});
|
|
}
|
|
} catch(e) {
|
|
console.log(e);
|
|
}
|