Skip to content

Latest commit

 

History

History
85 lines (63 loc) · 4.38 KB

README.md

File metadata and controls

85 lines (63 loc) · 4.38 KB

titoportas/update-project-fields

Use this action to automatically update GitHub project (beta) item fields. Note that this action does not support GitHub projects (classic).

The main difference between this lib and others is that you can use a PAT with repo and project scopes instead of org scope.

Usage

See action.yml for metadata that defines the inputs, outputs, and runs configuration for this action.

For more information about workflows, see Using workflows.

Create a workflow that will be triggered on Issues or Pull Requests events. It is highly recommended to use add-to-project action before in order to find/create an item in your project and then send the itemId as input to update-project-fields.

Once you've configured your workflow, save it as a .yml file in your target Repository's .github/workflows directory.

Example

name: Create and/or Update edited issues to my project

on:
  issues:
    types:
      - edited

jobs:
  create-update-project:
    name: Create/update project issue
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/[email protected] # This adds the issue to the project
        with:
          project-url: https://github.com/users/titoportas/projects/2
          github-token: ${{ secrets.GHPROJECT_SECRET }}
        id: add-project
      - uses: titoportas/[email protected]
        with:
          project-url: https://github.com/users/titoportas/projects/2
          github-token: ${{ secrets.GHPROJECT_SECRET }}
          item-id: ${{ steps.add-project.outputs.itemId }} # Use the item-id output of the previous step
          field-keys: TextField,NumberField,FinishedAt,Size,IterationField
          field-values: foo,123,2022-09-01,🐋 X-Large,[1]

Inputs

  • project-url (required) is the URL of the GitHub project to add issues to. eg: https://github.com/orgs|users/<ownerName>/projects/<projectNumber>
  • github-token (required) is a personal access token with repo and project scopes. See Creating a PAT and adding it to your repository for more details
  • item-id (required) project item id to be updated. Important: this id is not the issue/pull_request number.
  • field-keys (required) the github project field names separated with ,.
  • field-values (required) the github project field values associated to the field-keys separated with ,. If the key has values with special characters (eg: ✅ Done) you must include them.

Creating a PAT and adding it to your repository

Development

To get started contributing to this project, clone it and install dependencies. Note that this action runs in Node.js 16.x, so we recommend using that version of Node (see "engines" in this action's package.json for details).

> git clone https://github.com/titoportas/update-project-fields.git
> cd update-project-fields
> npm install

License

The scripts and documentation in this project are released under the MIT License

Special mentions

I want to say thanks to the authors and contributors of add-to-project and project-update. This Github action is based on both github projects.