2022-03-02 12:39:59 -05:00
# actions/add-to-project
2022-01-31 14:09:42 -05:00
2022-02-01 22:19:35 +00:00
Use this action to automatically add issues to a GitHub Project. Note that this
is for [GitHub Projects
(beta) ](https://docs.github.com/en/issues/trying-out-the-new-projects-experience/about-projects ),
not the original GitHub Projects.
2022-03-24 05:04:43 +00:00
## Current Status
2022-03-24 21:20:02 +00:00
[](https://github.com/actions/add-to-project/actions/workflows/test.yml)
2022-03-24 05:04:43 +00:00
🚨 **This action is a work-in-progress. Please do not use it except for
experimentation until a release has been prepared.** 🚨
## Usage
2022-03-24 06:18:57 +00:00
_See [action.yml](action.yml) for [metadata](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions) that defines the inputs, outputs, and runs configuration for this action._
_For more information about workflows, see [Using workflows](https://docs.github.com/en/actions/using-workflows)._
2022-02-01 22:19:35 +00:00
To use the action, create a workflow that runs when issues are opened in your
repository. Run this action in a step, optionally configuring any filters you
2022-03-23 12:34:57 +02:00
may want to add, such as only adding issues with certain labels. If you want to match all the labels, add `label-operator` input to be `AND` .
2022-01-31 14:09:42 -05:00
```yaml
2022-02-01 22:19:35 +00:00
name : Add bugs to bugs project
2022-01-31 14:09:42 -05:00
on :
2022-02-01 22:19:35 +00:00
issues :
types :
- opened
2022-01-31 14:09:42 -05:00
jobs :
add-to-project :
name : Add issue to project
runs-on : ubuntu-latest
steps :
2022-03-02 12:24:18 -05:00
- uses : actions/add-to-project@main
2022-01-31 14:09:42 -05:00
with :
project-url : https://github.com/orgs/<orgName>/projects/<projectNumber>
github-token : ${{ secrets.ADD_TO_PROJECT_PAT }}
2022-03-23 12:34:57 +02:00
labeled : bug, new
2022-03-24 23:08:45 +02:00
label-operator : AND
2022-01-31 14:09:42 -05:00
```
2022-03-24 22:06:12 +00:00
#### Further reading and additional resources
- [Inputs ](#inputs )
- [Supported Events ](#supported-events )
- [How to point the action to a specific branch or commit sha ](#how-to-point-the-action-to-a-specific-branch-or-commit-sha )
- [Creating a PAT and adding it to your repository ](creating-a-pat-and-adding-it-to-your-repository )
- [Development ](#development )
- [Publish to a distribution branch ](#publish-to-a-distribution-branch )
2022-02-01 22:19:35 +00:00
## Inputs
2022-01-31 14:09:42 -05:00
2022-03-25 00:14:19 +00:00
- <a name="project-url">`project-url` </a> ** (required)** is the URL of the GitHub Project to add issues to.
_eg: `https://github.com/orgs|users/<ownerName>/projects/<projectNumber>`_
2022-03-24 22:06:12 +00:00
- <a name="github-token">`github-token` </a> ** (required)** is a [personal access
2022-02-01 22:19:35 +00:00
token](https://github.com/settings/tokens/new) with the `repo` , `write:org` and
2022-03-24 22:06:12 +00:00
`read:org` scopes.
2022-03-24 06:18:57 +00:00
_See [Creating a PAT and adding it to your repository](creating-a-pat-and-adding-it-to-your-repository) for more details_
2022-03-24 22:06:12 +00:00
- <a name="labeled">`labeled` </a> ** (optional)** is a comma-separated list of labels used to filter applicable issues. When this key is provided, an issue must have _one_ of the labels in the list to be added to the project. Omitting this key means that any issue will be added.
2022-03-25 11:21:09 -07:00
- <a name="labeled">`label-operator` </a> ** (optional)** is the behavior of the labels filter, either `AND` or `OR` that controls if the issue should be matched with `all` `labeled` input or any of them, default is `OR` .
2022-01-31 15:46:31 -05:00
2022-03-24 06:18:57 +00:00
## Supported Events
Currently this action supports the following [issue events ](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issues ):
- `opened`
- `transferred`
2022-03-25 11:17:26 -07:00
- `labeled`
2022-03-24 06:18:57 +00:00
This ensures that all issues in the workflow's repo are added to the [specified project ](#project-url ). If [labeled input(s) ](#labeled ) are defined, then issues will only be added if they contain at least _one_ of the labels in the list.
## How to point the action to a specific branch or commit sha
Pointing to a branch name generally isn't the safest way to refer to an action, but this is how you can use this action now before we've begun creating releases.
```yaml
jobs :
add-to-project :
name : Add issue to project
runs-on : ubuntu-latest
steps :
- uses : actions/add-to-project@main
with :
project-url : https://github.com/orgs/<orgName>/projects/<projectNumber>
github-token : ${{ secrets.ADD_TO_PROJECT_PAT }}
```
Another option would be to point to a full [commit SHA ](https://docs.github.com/en/get-started/quickstart/github-glossary#commit ):
```yaml
jobs :
add-to-project :
name : Add issue to project
runs-on : ubuntu-latest
steps :
- uses : actions/add-to-project@<commitSHA>
with :
project-url : https://github.com/orgs/<orgName>/projects/<projectNumber>
github-token : ${{ secrets.ADD_TO_PROJECT_PAT }}
```
## Creating a PAT and adding it to your repository
- create a new [personal access
token](https://github.com/settings/tokens/new) with `repo` , `write:org` and
2022-03-24 22:06:12 +00:00
`read:org` scopes
_See [Creating a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) for more information_
2022-03-24 06:18:57 +00:00
2022-03-24 22:06:12 +00:00
- add the newly created PAT as a repository secret, this secret will be referenced by the [github-token input ](#github-token )
_See [Encrypted secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) for more information_
2022-03-24 06:18:57 +00:00
2022-02-01 22:19:35 +00:00
## Development
2022-01-31 14:09:42 -05:00
2022-02-01 22:19:35 +00:00
To get started contributing to this project, clone it and install dependencies.
2022-02-16 10:15:42 -05:00
Note that this action runs in Node.js 16.x, so we recommend using that version
2022-02-01 22:19:35 +00:00
of Node (see "engines" in this action's package.json for details).
2022-01-31 14:09:42 -05:00
2022-02-01 22:19:35 +00:00
```shell
> git clone https://github.com/actions/add-to-project
> cd add-to-project
> npm install
2022-01-31 14:09:42 -05:00
```
2022-02-01 22:19:35 +00:00
Or, use [GitHub Codespaces ](https://github.com/features/codespaces ).
2022-01-31 15:38:31 -05:00
2022-02-01 22:19:35 +00:00
See the [toolkit
documentation ](https://github.com/actions/toolkit/blob/master/README.md#packages )
for the various packages used in building this action.
2022-01-31 14:09:42 -05:00
## Publish to a distribution branch
2022-02-01 22:19:35 +00:00
Actions are run from GitHub repositories, so we check in the packaged action in
the "dist/" directory.
2022-01-31 14:09:42 -05:00
2022-02-01 22:19:35 +00:00
```shell
> npm run build
> git add lib dist
> git commit -a -m "Build and package"
> git push origin releases/v1
2022-01-31 14:09:42 -05:00
```
2022-02-01 22:19:35 +00:00
Now, a release can be created from the branch containing the built action.
2022-03-24 05:04:43 +00:00
# License
The scripts and documentation in this project are released under the [MIT License ](LICENSE )