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 👋
2024-06-12 17:59:55 -07:00
uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
2022-10-20 23:51:29 -07:00
- name : Check and close 🔐
2023-11-19 16:14:52 -08:00
uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
2022-10-20 23:51:29 -07:00
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;
}
2022-12-23 03:53:28 -08:00
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) or [themes channel](https://discord.com/channels/1023597603331526656/1055533233309233252) on Discord.`
2022-10-20 23:51:29 -07:00
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" ,
});