woocommerce / automations

Various GitHub Action automations to assist with repository project management.
MIT License
13 stars 6 forks source link
actions automations project-management

Project management automation

This is a GitHub Action which contains various automations to assist with project management in a GitHub repository.

Available Automations

Automation Description
todos This automation parses for @todo or @TODO comments in code and adds formatted pull request comments for each todo found. When a pull request is merged to the main branch, issues will be created for each @todo in the diff if there is not already an issue for that todo.
release This automation handles automating various parts of a somewhat opinionated release process.
assign-milestone This automation will assign the next milestone to a pull request once it has been approved.

Installation and Usage

To use the action, include it in your workflow configuration file:

on: pull_request
jobs:
    pull-request-automation:
        runs-on: ubuntu-latest
        steps:
            - uses: woocommerce/automations@v1
              with:
                  github_token: ${{ secrets.GITHUB_TOKEN }}
                  # This can be a comma delimited list of automations to run, in this case we're just executing todos
                  automations: todos

API

Inputs

Outputs

None.

Contributing

This will be expanded, but for reference:

Developing

Builds and releases

Adding a new automation.

The design of this repository is setup so that automations can be their own discrete thing (eg. "todos") but still take advantage of various scaffolding and boilerplate when creating a new automation. The following is a rough list of steps to take to create and add a new automation:

module.exports = {
    // the name of your automation
    name: 'my-automation',
    // what github action workflow events your automation reacts to.
    events: ['pull_request'],
    // what github action workflow event actions your automation reacts to.
    actions: ['opened'],
    // the runner for your automation.
    runner,
};
const todos = require('./automations/todos');
const myAutomation = require('./automations/my-automation');

const moduleNames = [todos, myAutomation];

/**
 * @typedef {import('./typedefs').AutomationTask} AutomationTask
 */

/**
 * @type {AutomationTask[]}
 */
const automations = moduleNames.map((module) => module);

module.exports = automations;

That's it!

Don't forget to add tests for your automation. There are various helpers available for mocking the context and octokit values (you can view the various todos automation tests for examples).

Credits