diff --git a/README.md b/README.md index 18da841..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": [ { @@ -111,7 +113,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..9eb1481 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' @@ -21,10 +24,11 @@ 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: | - if [ -z "$GH_TOKEN" ]; then + if [ -z "$GITHUB_AUTH_TOKEN" ]; then echo "Error: GH_TOKEN is not set." exit 1 fi @@ -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