From 7551db7af259b4b94e678589ffc7461930ffb548 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Fri, 18 Apr 2025 10:31:11 -0500 Subject: [PATCH 1/6] Make adjustments and fix the workflow Signed-off-by: Roger Barker --- README.md | 2 ++ action.yaml | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 18da841..9e05a90 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,9 @@ jobs: ## 👤 Author Roger Barker + [PandasWhoCode](https://pandaswhocode.com) + [roger@pandaswhocode.com](mailto:roger@pandaswhocode.com) --- \ No newline at end of file diff --git a/action.yaml b/action.yaml index 8416d9a..3fd03da 100644 --- a/action.yaml +++ b/action.yaml @@ -14,6 +14,9 @@ inputs: description: 'Path to the config file' required: true default: 'custom_props.json' + organization: + description: 'Github Organization' + required: true runs: using: 'composite' @@ -23,6 +26,7 @@ runs: env: GH_TOKEN: ${{ inputs.token }} CUSTOM_PROPS_FILE: ${{ inputs.config-file }} + ORGANIZATION: ${{ inputs.organization }} run: | if [ -z "$GH_TOKEN" ]; then echo "Error: GH_TOKEN is not set." @@ -34,4 +38,4 @@ runs: exit 1 fi - gh api -X PATCH /orgs/${GITHUB_REPOSITORY_OWNER}/properties/schema --input ${CUSTOM_PROPS_FILE} --silent + gh api -X PATCH /orgs/${ORGANIZATION}/properties/schema --input ${CUSTOM_PROPS_FILE} --silent From 1e251e8e445c6347bfd0a8b1c27e93cf8cf57236 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Fri, 18 Apr 2025 13:05:22 -0500 Subject: [PATCH 2/6] ensure doing an auth login Signed-off-by: Roger Barker --- action.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yaml b/action.yaml index 3fd03da..b601b45 100644 --- a/action.yaml +++ b/action.yaml @@ -37,5 +37,7 @@ runs: echo "Error: Custom properties file '${CUSTOM_PROPS_FILE}' does not exist." exit 1 fi + + gh auth login --with-token <<< "${GH_TOKEN}" gh api -X PATCH /orgs/${ORGANIZATION}/properties/schema --input ${CUSTOM_PROPS_FILE} --silent From b4b2decf62c05b716247948db972748ca031d8e7 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Fri, 18 Apr 2025 16:42:00 -0500 Subject: [PATCH 3/6] Update login section for github auth token Signed-off-by: Roger Barker --- action.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index b601b45..6d73796 100644 --- a/action.yaml +++ b/action.yaml @@ -24,7 +24,7 @@ runs: - 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: | @@ -38,6 +38,5 @@ runs: exit 1 fi - gh auth login --with-token <<< "${GH_TOKEN}" - + export GH_TOKEN=${GITHUB_AUTH_TOKEN} gh api -X PATCH /orgs/${ORGANIZATION}/properties/schema --input ${CUSTOM_PROPS_FILE} --silent From 0a4b03b67c527cfd9b5cff4d3bb5e7019071dd50 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Fri, 18 Apr 2025 16:43:29 -0500 Subject: [PATCH 4/6] Update GH_AUTH_TOKEN setup Signed-off-by: Roger Barker --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 6d73796..3b8bb86 100644 --- a/action.yaml +++ b/action.yaml @@ -28,7 +28,7 @@ runs: 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 From cbaf39596d3d9eef72076c84c8f41bd7a68e0a07 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Fri, 18 Apr 2025 16:50:49 -0500 Subject: [PATCH 5/6] chore: Update action and readme **Description**: Fixes the README and updates action so it works **Related Issue(s)**: Closes #3 Signed-off-by: Roger Barker --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9e05a90..8a79b1b 100644 --- a/README.md +++ b/README.md @@ -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. --- @@ -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": [ { From f0042bdff46f0704579e843a85f487211ea08163 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Fri, 18 Apr 2025 16:54:11 -0500 Subject: [PATCH 6/6] Update action.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Roger Barker --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 3b8bb86..9eb1481 100644 --- a/action.yaml +++ b/action.yaml @@ -28,7 +28,7 @@ runs: CUSTOM_PROPS_FILE: ${{ inputs.config-file }} ORGANIZATION: ${{ inputs.organization }} run: | - if [ -z "GITHUB_AUTH_TOKEN" ]; then + if [ -z "$GITHUB_AUTH_TOKEN" ]; then echo "Error: GH_TOKEN is not set." exit 1 fi