oh-my-posh/.github/workflows/close_themes_pr.yml

62 lines
2.1 KiB
YAML
Raw Normal View History

2022-10-20 23:51:29 -07:00
name: Close Themes PR
on:
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@8f4b7f84864484a7bf31766abe9204da3cbe65b3
2022-10-20 23:51:29 -07:00
- name: Check and close 🔐
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
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;
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;
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) 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({
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",
});