Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ To run the action within your github CI/CD pipeline you will need to create a
fine-grained token with the following permissions:

### Organization Permissions
- Read and Write access to organization administration

- Read, Write, and Admin access to organization custom properties

### Repository Permissions
- Read access to metadata
- Read and Write access to code and repository custom properties
### Additional Information

- [Create or update a custom property for an organization](https://docs.github.com/en/rest/orgs/custom-properties?apiVersion=2022-11-28#create-or-update-a-custom-property-for-an-organization)
- [Fine-grained personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token)
- The owner of the fine-grained token must have full administrative rights to the organization.

---

Expand All @@ -52,16 +54,16 @@ jobs:
with:
token: ${{ secrets.GH_ORG_ADMIN_TOKEN }}
config-file: .github/custom_props.json
organization: ${{ github.organization }}
```

---

## Example custom_props.json

```json

// custom_props.json
`custom_props.json`:

```json
{
"properties": [
{
Expand Down Expand Up @@ -111,7 +113,9 @@ jobs:
## 👤 Author

Roger Barker

[PandasWhoCode](https://pandaswhocode.com)

[roger@pandaswhocode.com](mailto:roger@pandaswhocode.com)

---
13 changes: 9 additions & 4 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ inputs:
description: 'Path to the config file'
required: true
default: 'custom_props.json'
organization:
description: 'Github Organization'
required: true

runs:
using: 'composite'
steps:
- name: Set Organization Custom Properties
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
GITHUB_AUTH_TOKEN: ${{ inputs.token }}
CUSTOM_PROPS_FILE: ${{ inputs.config-file }}
ORGANIZATION: ${{ inputs.organization }}
run: |
if [ -z "$GH_TOKEN" ]; then
if [ -z "$GITHUB_AUTH_TOKEN" ]; then
echo "Error: GH_TOKEN is not set."
exit 1
fi
Expand All @@ -33,5 +37,6 @@ runs:
echo "Error: Custom properties file '${CUSTOM_PROPS_FILE}' does not exist."
exit 1
fi

gh api -X PATCH /orgs/${GITHUB_REPOSITORY_OWNER}/properties/schema --input ${CUSTOM_PROPS_FILE} --silent

export GH_TOKEN=${GITHUB_AUTH_TOKEN}
gh api -X PATCH /orgs/${ORGANIZATION}/properties/schema --input ${CUSTOM_PROPS_FILE} --silent