Skip to content

Gthub action for Project (beta) management. Allows to update fields

License

Notifications You must be signed in to change notification settings

titoportas/update-project-fields

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

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/add-to-project@v0.3.0 # 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/update-project-fields@v0.1.0
        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.