Update readme with more useful info

This commit is contained in:
Jonathan Clem
2022-02-01 22:19:35 +00:00
committed by GitHub
parent b39b67e25e
commit 7e5edfd870
2 changed files with 43 additions and 89 deletions

130
README.md
View File

@@ -1,14 +1,24 @@
# @actions/add-to-project # @actions/add-to-project
**🚨 This action is a work in progress. Please do not use it except for experimentation until a release has been prepared. Thanks!** 🚨 This action is a work in progress. Please do not use it except for
experimentation until a release has been prepared. 🚨
Use this action to automatically add issues to a project when they're opened. 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.
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
may want to add, such as only adding issues with certain labels.
```yaml ```yaml
name: Add to project name: Add bugs to bugs project
on: on:
issues: {types: [opened]} issues:
types:
- opened
jobs: jobs:
add-to-project: add-to-project:
@@ -22,100 +32,44 @@ jobs:
labeled: bug labeled: bug
``` ```
Note that the `github-token` input must be a personal access token with ## Inputs
`read:org`, `write:org` (to get and update projects) and `repo` scope (for
adding repo issues to the project).
The `labeled` key is optional, and if specified, the action will only add issues - `project-url` is the URL of the GitHub Project to add issues to.
that have at least one of the specified labels. This should be a comma-delimited - `github-token` is a [personal access
string of label names. token](https://github.com/settings/tokens/new) with the `repo`, `write:org` and
`read:org` scopes.
- `labeled` is a comma-separated list of labels. For an issue to be added to the
project, it must have _one_ of the labels in the list. Omitting this key means
that all issues will be added.
## Code in Main ## Development
> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance. To get started contributing to this project, clone it and install dependencies.
Note that this action runs in Node.js 12.x, so we recommend using that version
of Node (see "engines" in this action's package.json for details).
Install the dependencies ```shell
> git clone https://github.com/actions/add-to-project
```bash > cd add-to-project
$ npm install > npm install
``` ```
Build the typescript and package it for distribution Or, use [GitHub Codespaces](https://github.com/features/codespaces).
```bash See the [toolkit
$ npm run build documentation](https://github.com/actions/toolkit/blob/master/README.md#packages)
``` for the various packages used in building this action.
Run the tests :heavy_check_mark:
```bash
$ npm test
PASS ./index.test.js
...
```
## Change action.yml
The action.yml defines the inputs and output for your action.
Update the action.yml with your name, description, inputs and outputs for your action.
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
## Change the Code
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
```javascript
import * as core from '@actions/core';
...
async function run() {
try {
...
}
catch (error) {
core.setFailed(error.message);
}
}
run()
```
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
## Publish to a distribution branch ## Publish to a distribution branch
Actions are run from GitHub repos so we will checkin the packed dist folder. Actions are run from GitHub repositories, so we check in the packaged action in
the "dist/" directory.
Then run [ncc](https://github.com/zeit/ncc) and push the results: ```shell
> npm run build
```bash > git add lib dist
$ npm run package > git commit -a -m "Build and package"
$ git add dist > git push origin releases/v1
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1
``` ```
Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project. Now, a release can be created from the branch containing the built action.
Your action is now published! :rocket:
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
## Validate
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml))
```yaml
uses: ./
with:
milliseconds: 1000
```
See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket:
## Usage:
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action

View File

@@ -8,7 +8,7 @@
"@actions/github": "^5.0.0" "@actions/github": "^5.0.0"
}, },
"engines": { "engines": {
"node": ">=10.0.0 <17.0.0", "node": ">=12.0.0 <17.0.0",
"npm": ">= 7.0.0" "npm": ">= 7.0.0"
}, },
"devDependencies": { "devDependencies": {