-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from alexh97/project-assigner
Moving the source from my private repo to Elastic's repo
- Loading branch information
Showing
7 changed files
with
29,042 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
This repository contains various GitHub actions that the Elastic team has developed to help us automate some common processes. Each action appears in it own folder. | ||
|
||
To use these actions in your GitHub workfkflows, include them in the workflow configuration file step config. For example: | ||
|
||
steps: | ||
- name: Assign to project | ||
uses: elastic/github-actions/[email protected] | ||
id: project_assigner | ||
with: | ||
issue-mappings: '[{"label": "Test", "projectName": "test", "columnId": 1234}, | ||
{"label": "bug", "projectName": "test2", "columnId": 5678}]' | ||
ghToken: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Project Assigner GitHub Action | ||
|
||
This is a GitHub action, implemented in JavaScript, which does the following: | ||
- Assigns an issue or pull request to a project when a specified label is applied | ||
- Removes an issue or pull request from a project when a specified label is removed | ||
|
||
You can provide multiple label to project mappings as the action input. | ||
|
||
## Inputs | ||
|
||
### `issue-mappings` | ||
A JSON array of objects containing `label`, `projectName`, and `columnId` attributes. | ||
|
||
**`label`** - name of the GitHub label that should trigger this action when it's applied to or removed from an issue or a pull request. | ||
|
||
**`projectName`** - name of the project that an issue or pull request should be assinged to when the label is applied, or removed from when the label is removed. | ||
|
||
**`columnId`** - *ID* of the GitHub project column that an issue or a pull request should be placed in when they're assigned to the project. For issues, this would typically be the ID of the "To Do" column. For pull requests, this may be the ID of the "In Review" column. You should use your own discression when choosing which columns to use for your particular project. A column ID can be found by copying the column URL using its "..." menu and then using the numeric ID at the end of the URL as the value for `columnId`. | ||
|
||
Here's a sample format of the `issue-mappings` input: | ||
|
||
issue-mappings: '[{"label": "Test", "projectName": "test", "columnId": 1234}, | ||
{"label": "bug", "projectName": "test2", "columnId": 5678}]' | ||
|
||
## Example usage | ||
|
||
In order to use this action, create a workflow configuration file (e.g. `issues-workflow.yml`) in your repository's `.github/workflows` directory. *Note that you need to have GitHub Actions enabled for your repository in order for this to work!* | ||
|
||
### A workflow configuration for assigning issues to projects | ||
|
||
on: | ||
issues: | ||
types: [labeled, unlabeled] | ||
|
||
jobs: | ||
assign_to_project: | ||
runs-on: ubuntu-latest | ||
name: Assign an issue to project based on label | ||
steps: | ||
- name: Assign to project | ||
uses: elastic/github-actions/[email protected] | ||
id: project_assigner | ||
with: | ||
issue-mappings: '[{"label": "Test", "projectName": "test", "columnId": 1234}, | ||
{"label": "bug", "projectName": "test2", "columnId": 5678}]' | ||
ghToken: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
### A workflow configuration for assigning pull requests to projects | ||
|
||
on: | ||
pull_request: | ||
types: [labeled, unlabeled] | ||
|
||
jobs: | ||
assign_to_project: | ||
runs-on: ubuntu-latest | ||
name: Assign a PR to project based on label | ||
steps: | ||
- name: Assign to project | ||
uses: elastic/github-actions/[email protected] | ||
id: project_assigner | ||
with: | ||
issue-mappings: '[{"label": "Test", "projectName": "test", "columnId": 1234}, | ||
{"label": "enhancement", "projectName": "test2", "columnId": 5678}]' | ||
ghToken: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: 'Project Assigner' | ||
description: 'Assigns an issue to a project based on its lable at the time it is opened or labeled' | ||
inputs: | ||
issue-mappings: | ||
description: 'A JSON array of objects containing label, projectName, and columnId attributes' | ||
required: true | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' |
Oops, something went wrong.