Auto Update Project Fields on Issue Close
ActionsTags
(2)This GitHub Action automatically updates custom fields of items in an Organization Project (GitHub Projects v2) when an issue is closed. It is designed for organizations using GitHub Projects (v2) to track issues and automate field updates based on configurable rules.
- Automated Field Updates: Updates custom fields for project items when issues are closed.
- Supports Multiple Field Types: Number, SingleSelect, Date, and Text fields are supported.
- Configurable: Supports custom field configuration via a JSON file.
- Secure: Requires a GitHub token for authentication.
Add the following to your workflow YAML:
on:
issues:
types: [closed]
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
jobs:
update-custom-fields:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update Project Item Custom Fields
uses: DevOpsVisions/project-fields-updater@main
with:
org: ${{ github.repository_owner }}
project_number: 52
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.issue.number }}
config_path: configs/fields-config.json
Name | Description | Required | Default |
---|---|---|---|
org | The organization name | Yes | - |
project_number | The project number | Yes | - |
owner | The repository owner | Yes | - |
repo | The repository name | Yes | - |
issue_number | The issue number | Yes | - |
config_path | Path to the fields-config.json file | No | fields-config.json |
Supported field types: Number, SingleSelect, Date, and Text.
Create a fields-config.json
file in your repository to specify which fields to update and how. Example:
[
{
"field_name": "Week",
"field_type": "number",
"field_value": "30"
},
{
"field_name": "Month",
"field_type": "singleSelect",
"field_value": "Jul"
},
{
"field_name": "Date",
"field_type": "date",
"field_value": "2025-07-22"
},
{
"field_name": "Reason",
"field_type": "text",
"field_value": "Reason for the change"
}
]
In our organization, we initially created this action to automatically update the following fields when closing an issue:
- Week: with the current week number
- Month: with the current month (e.g., "Jul")
- Date: with the current date
If this matches your use case, set the field_value
to auto
for these fields in your config, and the action will update them with the current values automatically.
Example (fields-config.json
):
[
{
"field_name": "Week",
"field_type": "number",
"field_value": "auto"
},
{
"field_name": "Month",
"field_type": "singleSelect",
"field_value": "auto"
},
{
"field_name": "Date",
"field_type": "date",
"field_value": "auto"
}
]
- Install GitHub CLI: The action installs the GitHub CLI (
gh
) for API access. - Find Project Item: Locates the project item for the closed issue.
- Update Fields: Updates the specified fields using the configuration file.
- Organization Projects (GitHub Projects v2)
- GitHub CLI (
gh
) GITHUB_TOKEN
with the following permissions:- Organization permissions: Read and Write access to issue fields and organization projects
- Repository permissions: Read access to code, issues, and metadata
Scripts are located in src/scripts/
:
entrypoint.sh
: Main entry pointget-project-info.sh
: Fetches project infofind-item-id.sh
: Finds the project item IDupdate-fields.sh
: Updates custom fields
MIT
DevOpsVisions
Auto Update Project Fields on Issue Close is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.