Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #11

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 92 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,73 @@
# Update Project V2 Item Field

Update the field of a project v2 item.

Notice: Thie action is in progress.
A GitHub Actions to update the field of a GitHub project v2 item.

## Use Case

- After requesting a review, change the status to "In Review".
- Set Current Date to "Closed Date" field when the issue is closed.
- Calculate "Time to Close Days" to handle project management.
- [WIP] Calculate "Time to Close Days" to handle project management.

## Example Usage

TODO
### After requesting a review, change the status to "In Review".

```yml
name: Update status to "In Review"
on:
pull_request:
types: [review_requested]

jobs:
update-status:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Update status to "In Review"
uses: nipe0324/[email protected]
with:
project-url: https://github.com/orgs|users/<ownerName>/projects/<projejctNumer>
github-token: ${{ secrets.UPDATE_PROJECT_V2_PAT }}
field-name: "Status"
field-value: "In Review"
```

### Set Current Date to "Closed Date" field when the issue is closed.

```yml
name: Set "Closed Date"
on:
issues:
types: [closed]

jobs:
set-closed-date:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Get current date
id: current-date
# Note: Default timezone is UTC. Use TZ env to change timezone.
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Set "Closed Date"
uses: nipe0324/update-project-v2-item-field@main
with:
project-url: https://github.com/orgs|users/<ownerName>/projects/<projejctNumer>
github-token: ${{ secrets.UPDATE_PROJECT_V2_PAT }}
field-name: "Closed Date"
field-value: "${{ steps.current-date.outputs.date }}"
```

Reference: Github Actions Triggers: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows

## Inputs

- `project-url` **(required)** is the URL of the GitHub project v2 to update item field.
_eg: `https://github.com/orgs|users/<ownerName>/projects/<projectNumber>`_
- `github-token` **(required)** is a [personal access
token](https://github.com/settings/tokens/new) with `repo` and `project` scopes.
token](https://github.com/settings/tokens/new) with `repo` and `project` scopes. [more detail](#tokens)
- `field-name` **(required)** is a field name of the project v2 item to update.
_note: Supported field types are `text`, `number`, `date` and `single_select`._
- `field-value` **(required)** is a field value of the project v2 item to update.
Expand All @@ -28,6 +76,28 @@ TODO

- `item-id` is the ID of the project v2 updated item.

## FAQ

### Supported field types

The action supports the following field data types:

| Field Type | GraphQL Type | Description |
| :-----------: | :--------------: | :------------------------------------------------------------: |
| Text | String | The literal string in the field. eg: `"Hello World"` |
| Number | Float | The string representation of a number. eg: `"100.1"` |
| Date | Date | The date in the YYYY-MM-DD format. eg: `"2024-01-01"` |
| Single Select | String | The name of the option (must be an exact match) |

### Tokens

Your token **has to be a classic PAT(Personal Access Token)**: the new fine-grained tokens do not work with the GraphQL API yet. You can create PAT from https://github.com/settings/tokens/new.

The token should have the following scopes:

- `repo`: needed read issues and PRs from private repositories. If you're using the action on a public repository, you can just use `public_repo` instead.
- `project`: needed to update project fields.

## Development

```shell
Expand All @@ -41,3 +111,19 @@ Run all tests (format, lint, test, coverage, package)
```shell
npm run all
```

## Publish to a distribution branch

Actions are run from GitHub repositories, so we check in the packaged action in
the "dist/" directory.

```shell
npm run all
git tag v1.0.0
```

Now, a release can be created from the branch containing the built action.

# License

The scripts and documentation in this project are released under the [MIT License](LICENSE)
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@nipe0324/update-project-v2-item-field",
"description": "Update Project v2 Item Field",
"version": "0.0.0",
"version": "1.0.0",
"author": "nipe0324",
"keywords": [
"actions",
"node",
"setup"
"project",
"card"
],
"exports": {
".": "./dist/index.js"
Expand All @@ -27,6 +27,10 @@
"all": "npm run format:write && npm run lint && npm run test && npm run coverage && npm run package"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/nipe0324/update-project-v2-item-field.git"
},
"jest": {
"preset": "ts-jest",
"verbose": true,
Expand Down
Loading