/assign-to-repository-projects

Github Action asigning pull requests to GitHub projects of a repository

Primary LanguageJavaScriptMIT LicenseMIT

assign-to-repository-projects

Github Action assigning pull requests to GitHub projects of a repository.

Context

This GitHub Action assigns a pull request to GitHub projects (aka Projects V2). The intended use case is, that a PR given by pull_request type GitHub action event should be assigned to one or more projects. The projects are give by a list of project titles. For each title, the PR is assigned to the matching project. After that the resulting project item's Status field value is set to Todo, additionally. (The field Status and the single select option Todo are created by default with any project by API and are assumed to exist.) The action is idempotent for GitHub projects given the same inputs.

Requirements

This GitHub action expects an GitHub action event of type push.

Moreover, the GitHub token of a GitHub App installation is expected as environment variable GITHUB_TOKEN. The GitHub App requires the following permissions.

  • Read access to administration and metadata
  • Read and write access to code, organization projects and pull requests

Inputs

Name Description Type Required?
project-titles Space-separated list of titles of projects linked to this repository the PR will be assigned to string YES

Outputs

Name Description Type
project-titles Space-separated list of titles of projects in this repository the PR has been assigned to string

Build process

Instead of checking in node_modules for the JavaScript action we are using ncc. To build the project run npm run build.

Tests

This project is using Jest for testing. Combining Jest and ES modules requires setting node flag --experimental-vm-modules. Run the tests as follows.

NODE_OPTIONS='--experimental-vm-modules' npm run test