2022-10-20 23:51:29 -07:00
name : Close Themes PR
on :
2022-10-21 05:18:46 -07:00
pull_request_target :
2022-10-21 05:27:46 -07:00
types :
- opened
2022-10-20 23:51:29 -07:00
jobs :
2022-10-21 05:27:46 -07:00
check :
2022-10-20 23:51:29 -07:00
runs-on : ubuntu-latest
steps :
- name : Checkout code 👋
uses : actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- name : Check and close 🔐
uses : actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0
with :
2022-10-21 05:11:13 -07:00
github-token : ${{ secrets.GH_PAT }}
2022-10-20 23:51:29 -07:00
script : |
const { repo: { owner, repo } } = context;
2022-10-21 01:01:58 -07:00
const pr = context.payload.pull_request;
2022-10-20 23:51:29 -07:00
const response = await github.rest.pulls.listFiles({
owner, repo,
pull_number : pr.number
});
if (response.status !== 200) {
console.log('Could not fetch files');
return;
}
let hasThemeAdditions = false;
2022-10-21 00:50:06 -07:00
for (const file of response.data) {
2022-10-21 00:00:06 -07:00
const name = file.filename
console.log(`File : ${name}`);
if (file.status === 'added' && name.includes('themes/')) {
console.log(`File : ${name} is a theme addition`);
2022-10-20 23:51:29 -07:00
hasThemeAdditions = true;
break;
}
}
if (!hasThemeAdditions) {
2022-10-21 00:00:06 -07:00
console.log('No theme additions found.');
2022-10-20 23:51:29 -07:00
return;
}
const body = `👋 @${pr.user.login}, theme aditions are no longer accepted due to the ever growing set. We do however accept showcasing your custom theme in the [🎨 Themes section](https://github.com/JanDeDobbeleer/oh-my-posh/discussions/categories/themes) in discussions.`
2022-10-21 05:27:46 -07:00
console.log(`Adding comment : ${body}`);
2022-10-20 23:51:29 -07:00
await github.rest.issues.createComment({
2022-10-21 00:50:06 -07:00
owner, repo,
2022-10-20 23:51:29 -07:00
issue_number : pr.number,
body,
});
2022-10-21 05:27:46 -07:00
console.log(`Closing pull request : ${pr.html_url}`);
2022-10-20 23:51:29 -07:00
await github.rest.pulls.update({
owner, repo,
pull_number : pr.number,
state : "closed" ,
});