As part of the project A bot has been created for GitHub that addresses tasks related to enforcing self-service for repository users. On GitHub, there are repositories whose only function is to coordinate people through the Issue system. In some of these, users submitting Issues are asked to fill out a form. Then a moderator comes in, checks the accuracy of the form, and applies tags according to those specified in the form (only privileged users can apply tags if they are not set in the template). An example of such a community is .
The moderator does not arrive instantaneously. Therefore, for checking forms and performing operations the GitHub Action presented in the news. The bot is written in Python, but it still has to be run through node.js since GitHub has only two types of actions — node.js and docker. For docker, the same container loads first, where node.js is, and another container is then loaded into it, which is slow. Considering that the container with node.js already has python3 and all the necessary components, it's rational to simply load dependencies into it, especially since they are not large.
Features:
- The action is controlled via a YAML config and Markdown templates;
- Each Markdown template includes a block describing the conditions for correctly filling out the form and the desired actions;
- A configuration file with global settings is added;
- Forms consist of sections. There are 2 types of sections:
- Free text. The action can check that the user made an effort to fill something in there. The coherence of the text is not automatically verified.
- Checkboxes. It is possible to require filling in n checkboxes, such that 0 {= m1 {= n {= m2 {= total number of checkboxes in the section. The action checks that the checkboxes correspond to those in the template. If the checkboxes are set correctly, the action can apply tags to the issue according to the checkboxes.
- If the form is filled out incorrectly, the action instructs the user on how to fill it out correctly and applies a special label.
- If the form is not corrected within a certain period, the action may close the issue. Automatic banning of users, removal, and moving issues are not yet implemented due to the lack of an official API for the necessary actions and issues with state maintenance.
- If the problem is resolved, the action removes the label.
- Response templates for actions are, of course, customizable.
Source: opennet.ru
