Skip to content
layout

GitHub Action

Project Fields

v2.0.2 Latest version

Project Fields

layout

Project Fields

A GitHub Action to interact with project fields

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Project Fields

uses: EndBug/[email protected]

Learn more about this action in EndBug/project-fields

Choose a version

Project Fields

A GitHub actions to get and set GitHub project fields.

Table of Contents

Inputs

Here's the complete list of inputs for this action, also available in the action.yml file.
For a minimal/typical usage, check out the examples section.

- uses: EndBug/project-fields@v2
  with:
    # ⬇️ Required inputs ⬇️

    # The type of field operation. Valid options are "get", "set", "clear"
    operation: get

    # A comma-separated list of fields to get or set
    # See the FAQ section for a list of supported field types
    fields: text,number,date,select

    # The GitHub token to use for authentication
    # This token should have write access to the project, and read access
    # to the issue/PR you're referencing (see the FAQ section for more info)
    github_token: ${{ secrets.PROJECT_PAT }}

    # The URL of the project
    project_url: https://github.com/users/OWNER/projects/123

    # ⬇️ Optional inputs ⬇️

    # The URL of the issue/PR to reference
    # Default: the issue/PR that triggered the workflow run
    resource_url: https://github.com/OWNER/REPO/issues/123

    # A comma-separated list of values to update the fields with
    # The list must have the same length as the fields one, since they have to match up
    # Default: ''
    values: abc,123,2000-10-30,option

Outputs

The action provides only one output:

  • values: a comma-separated list of the current values of the fields

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
Number Float The string representation of a number
Date Date The date in the YYYY-MM-DD format
Single Select String The name of the option (must be an exact match)

Tokens

Your token has to be a classic PAT: the new fine-grained tokens do not work with the GraphQL API yet.

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. If you're only using the action to get the fields, you can just use read:project instead.

Examples

Get field values

on: [issues, pull_request]

# ...

- uses: EndBug/project-fields@v2
  id: fields
  with:
    operation: get
    fields: text,number,date,select
    github_token: ${{ secrets.PROJECT_PAT }}
    project_url: https://github.com/OWNER/REPO/issues/123

- run: echo ${{ steps.fields.outputs.values }}

Update field values

on: [issues, pull_request]

# ...

- name: Set outputs A and B
  id: script
  run: # ...

- uses: EndBug/project-fields@v2
  with:
    operation: set
    fields: first,second
    github_token: ${{ secrets.PROJECT_PAT }}
    project_url: https://github.com/OWNER/REPO/issues/123
    values: ${{ steps.script.outputs.a }},${{ steps.script.outputs.b }}

Clear fields

on: [issues, pull_request]

# ...

- uses: EndBug/project-fields@v2
  with:
    operation: clear
    fields: first,second
    github_token: ${{ secrets.PROJECT_PAT }}
    project_url: https://github.com/OWNER/REPO/issues/123

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Federico Grandi
Federico Grandi

💻
Ben
Ben

💻
Nicolas Yarosz
Nicolas Yarosz

🚧
Add your contributions

This project follows the all-contributors specification. Contributions of any kind welcome!

Additional credits

This project has started thanks to the input of the
GitHub Campus Experts Program 🚩

License

This project is distributed under the MIT License, check the license file for more info.