Skip to content

Commit e831adc

Browse files
committed
Project Fields Updater
1 parent 5d4b1d8 commit e831adc

File tree

25 files changed

+350
-1
lines changed

25 files changed

+350
-1
lines changed

README.md

Lines changed: 131 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,134 @@
1-
# Template
1+
# Auto Update Project Fields on Issue Close
2+
3+
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.
4+
5+
## Features
6+
- **Automated Field Updates:** Updates custom fields for project items when issues are closed.
7+
- **Supports Multiple Field Types:** Number, SingleSelect, Date, and Text fields are supported.
8+
- **Configurable:** Supports custom field configuration via a JSON file.
9+
- **Secure:** Requires a GitHub token for authentication.
10+
11+
## Usage
12+
Add the following to your workflow YAML:
13+
14+
```yaml
15+
on:
16+
issues:
17+
types: [closed]
18+
19+
jobs:
20+
update-project-fields:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
- name: Update Project Fields
26+
uses: DevOpsVisions/project-fields-updater@main
27+
with:
28+
org: "your-org"
29+
project_number: "your-project-number"
30+
owner: "your-repo-owner"
31+
repo: "your-repo-name"
32+
issue_number: "${{ github.event.issue.number }}"
33+
config_path: "fields-config.json" # Optional, defaults to fields-config.json
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
```
37+
38+
## Inputs
39+
| Name | Description | Required | Default |
40+
|----------------|--------------------------------------|----------|----------------------|
41+
| org | The organization name | Yes | - |
42+
| project_number | The project number | Yes | - |
43+
| owner | The repository owner | Yes | - |
44+
| repo | The repository name | Yes | - |
45+
| issue_number | The issue number | Yes | - |
46+
| config_path | Path to the fields-config.json file | No | fields-config.json |
47+
48+
## Field Configuration
49+
Supported field types: **Number**, **SingleSelect**, **Date**, and **Text**.
50+
51+
Create a `fields-config.json` file in your repository to specify which fields to update and how. Example:
52+
53+
```json
54+
[
55+
{
56+
"field_name": "Week",
57+
"field_type": "number",
58+
"field_value": "30"
59+
},
60+
{
61+
"field_name": "Month",
62+
"field_type": "singleSelect",
63+
"field_value": "Jul"
64+
},
65+
{
66+
"field_name": "Date",
67+
"field_type": "date",
68+
"field_value": "2025-07-22"
69+
},
70+
{
71+
"field_name": "Reason",
72+
"field_type": "text",
73+
"field_value": "Reason for the change"
74+
}
75+
]
76+
```
77+
### Organization Default Use Case
78+
79+
In our organization, we initially created this action to automatically update the following fields when closing an issue:
80+
- **Week**: with the current week number
81+
- **Month**: with the current month (e.g., "Jul")
82+
- **Date**: with the current date
83+
84+
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.
85+
86+
Example (`fields-config.json`):
87+
88+
```json
89+
[
90+
{
91+
"field_name": "Week",
92+
"field_type": "number",
93+
"field_value": "auto"
94+
},
95+
{
96+
"field_name": "Month",
97+
"field_type": "singleSelect",
98+
"field_value": "auto"
99+
},
100+
{
101+
"field_name": "Date",
102+
"field_type": "date",
103+
"field_value": "auto"
104+
}
105+
]
106+
```
107+
108+
## How It Works
109+
1. **Install GitHub CLI:** The action installs the GitHub CLI (`gh`) for API access.
110+
2. **Find Project Item:** Locates the project item for the closed issue.
111+
3. **Update Fields:** Updates the specified fields using the configuration file.
112+
113+
## Requirements
114+
- Organization Projects (GitHub Projects v2)
115+
- GitHub CLI (`gh`)
116+
- `GITHUB_TOKEN` with the following permissions:
117+
- **Organization permissions:** Read and Write access to issue fields and organization projects
118+
- **Repository permissions:** Read access to code, issues, and metadata
119+
120+
## Scripts
121+
Scripts are located in `src/scripts/`:
122+
- `entrypoint.sh`: Main entry point
123+
- `get-project-info.sh`: Fetches project info
124+
- `find-item-id.sh`: Finds the project item ID
125+
- `update-fields.sh`: Updates custom fields
126+
127+
## License
128+
MIT
129+
130+
## Author
131+
DevOpsVisions
2132

3133

4134

action.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Auto Update Project Fields on Issue Close'
2+
description: 'This action automatically updates custom fields of items in a GitHub Project when an issue is closed.'
3+
author: 'Your Name'
4+
runs:
5+
using: 'composite'
6+
steps:
7+
- name: Install GitHub CLI
8+
shell: bash
9+
run: |
10+
sudo apt-get update
11+
sudo apt-get install gh -y
12+
13+
- name: Ensure action scripts are executable
14+
shell: bash
15+
run: |
16+
chmod +x ${{ github.action_path }}/src/scripts/*.sh
17+
18+
- name: Run entrypoint.sh
19+
shell: bash
20+
run: |
21+
${{ github.action_path }}/src/scripts/entrypoint.sh \
22+
"${{ inputs.org }}" \
23+
"${{ inputs.project_number }}" \
24+
"${{ inputs.owner }}" \
25+
"${{ inputs.repo }}" \
26+
"${{ inputs.issue_number }}" \
27+
"${{ inputs.config_path }}"
28+
inputs:
29+
org:
30+
description: 'The organization login.'
31+
required: true
32+
project_number:
33+
description: 'The project number.'
34+
required: true
35+
owner:
36+
description: 'The repository owner.'
37+
required: true
38+
repo:
39+
description: 'The repository name.'
40+
required: true
41+
issue_number:
42+
description: 'The issue number.'
43+
required: true
44+
45+
config_path:
46+
description: 'Path to the fields-config.json file.'
47+
required: false
48+
default: 'fields-config.json'

src/app/..txt

Whitespace-only changes.

src/db/configs/..txt

Whitespace-only changes.

src/db/constraints/..txt

Whitespace-only changes.

src/db/indexes/..txt

Whitespace-only changes.

src/db/migrations/..txt

Whitespace-only changes.

src/db/schemas/..txt

Whitespace-only changes.

src/db/scripts/..txt

Whitespace-only changes.

src/db/seed-data/..txt

Whitespace-only changes.

0 commit comments

Comments
 (0)