From 56bf3f1fdeb07602230e248cf442da1368ae6576 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Tue, 22 Apr 2025 18:51:37 -0500 Subject: [PATCH 1/4] docs: update readme Signed-off-by: Andrew Brandt --- README.md | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5ffa111..36ae99c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,80 @@ -# read-all-custom-properties +# README for the project Read All Custom Properties -Github Action to read all custom properties from all repos in an organization. \ No newline at end of file +**Read all custom properties and values from all repos in the organization and write to a file.** + +This action uses the GitHub CLI to read all properties from all repos in the organization. It can write +the results to a `repo-properties.yaml` file as well, for use with input to +[update custom properties](https://github.com/PandasWhoCode/update-custom-properties) action. + +--- + +## 🚀 Getting Started + +1. Add this GitHub Action to your workflow. +2. Run the workflow. A new commit will be generated on the branch you run it from containing the `repo-properties.yaml` +file. + +--- + +## Fine Grained Token Requirements + +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 access to organization custom properties + +### Additional Information + +- [Github API for 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. + +--- + +## 📦 Inputs + +| Name | Description | Required | Default | +|---------------------------|------------------------------------------------------------------------|-----|---------| +| `token` | GitHub Personal Access Token (Fine-Grained with `Read` org scope) | ✅ Yes | — | +| `overwrite-existing-file` | Boolean for choosing to overwrite `repo-properties.json`, if it exists | 🟥 No | `false` | +| `dry-run-enabled` | Flag to dry-run the script, will not commit in repo. | 🟥 No | `false` | +| `commit-author-name` | Author Name on the commit that will be created | ✅ Yes | - | +| `commit-author-email` | Author Email on the commit that will be created | ✅ Yes | - | +| `commit-author-gpg-key-contents` | GPG Key for the commit that will be created (must match the `email`) | ✅ Yes | - | +| `commit-author-gpg-key-passphrase` | GPG Key Passphrase for the key to sign the commit that will be created | ✅ Yes | - | + +--- + +## 🛠 Usage + +```yaml +jobs: + update-schema: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: PandasWhoCode/read-all-custom-properties@1-create-an-action-to-read-all-custom-properties + with: + token: ${{ secrets.GH_CUSTOM_PROPS_TOKEN_WRITABLE }} + overwrite-existing-file: ${{ inputs.overwrite-existing-file }} + dry-run-enabled: ${{ inputs.dry-run-enabled }} + commit-author-name: ${{ inputs.commit-author-name }} + commit-author-email: ${{ inputs.commit-author-email }} + commit-author-gpg-key-contents: ${{ secrets.GPG_KEY_CONTENTS }} + commit-author-gpg-key-passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }} +``` + +--- + +## 👤 Author + +Andrew Brandt + +[PandasWhoCode](https://pandaswhocode.com) + +[andrew.brandt@pandaswhocode.com](mailto:andrew.brandt@pandaswhocode.com) + +--- \ No newline at end of file From 6a205212612d0b43eea08e7375fe07b21fd3bfb8 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Tue, 22 Apr 2025 18:59:59 -0500 Subject: [PATCH 2/4] fix table formatting Signed-off-by: Andrew Brandt --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 36ae99c..4765644 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ file. ## Fine Grained Token Requirements -To run the action within your Github CI/CD pipeline you will need to create a +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 @@ -27,7 +27,7 @@ fine-grained token with the following permissions: ### Additional Information -- [Github API for 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) +- [GitHub API for 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. @@ -35,15 +35,15 @@ fine-grained token with the following permissions: ## 📦 Inputs -| Name | Description | Required | Default | -|---------------------------|------------------------------------------------------------------------|-----|---------| -| `token` | GitHub Personal Access Token (Fine-Grained with `Read` org scope) | ✅ Yes | — | -| `overwrite-existing-file` | Boolean for choosing to overwrite `repo-properties.json`, if it exists | 🟥 No | `false` | -| `dry-run-enabled` | Flag to dry-run the script, will not commit in repo. | 🟥 No | `false` | -| `commit-author-name` | Author Name on the commit that will be created | ✅ Yes | - | -| `commit-author-email` | Author Email on the commit that will be created | ✅ Yes | - | -| `commit-author-gpg-key-contents` | GPG Key for the commit that will be created (must match the `email`) | ✅ Yes | - | -| `commit-author-gpg-key-passphrase` | GPG Key Passphrase for the key to sign the commit that will be created | ✅ Yes | - | +| Name | Description | Required | Default | +|------------------------------------|------------------------------------------------------------------------|----------|---------| +| `token` | GitHub Personal Access Token (Fine-Grained with `Read` org scope) | ✅ Yes | — | +| `overwrite-existing-file` | Boolean for choosing to overwrite `repo-properties.json`, if it exists | 🟥 No | `false` | +| `dry-run-enabled` | Flag to dry-run the script, will not commit in repo. | 🟥 No | `false` | +| `commit-author-name` | Author Name on the commit that will be created | ✅ Yes | - | +| `commit-author-email` | Author Email on the commit that will be created | ✅ Yes | - | +| `commit-author-gpg-key-contents` | GPG Key for the commit that will be created (must match the `email`) | ✅ Yes | - | +| `commit-author-gpg-key-passphrase` | GPG Key Passphrase for the key to sign the commit that will be created | ✅ Yes | - | --- From 6a01a1134fe20110f6e024ecf3827976ca51f786 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Wed, 23 Apr 2025 07:46:05 -0500 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Roger Barker Signed-off-by: Andrew Brandt --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4765644..578e552 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,11 @@ fine-grained token with the following permissions: - Read access to organization custom properties +### Repository Permissions + +- Read access to Repository Metadata +- Read and Write access to Repository contents + ### Additional Information - [GitHub API for 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) @@ -37,7 +42,7 @@ fine-grained token with the following permissions: | Name | Description | Required | Default | |------------------------------------|------------------------------------------------------------------------|----------|---------| -| `token` | GitHub Personal Access Token (Fine-Grained with `Read` org scope) | ✅ Yes | — | +| `token` | GitHub Personal Access Token (Fine-Grained with: Organization custom properties `Read`, Repository contents `Read and Write` scope) | ✅ Yes | — | | `overwrite-existing-file` | Boolean for choosing to overwrite `repo-properties.json`, if it exists | 🟥 No | `false` | | `dry-run-enabled` | Flag to dry-run the script, will not commit in repo. | 🟥 No | `false` | | `commit-author-name` | Author Name on the commit that will be created | ✅ Yes | - | From cfee8ce8fe583139cd29e8e9fdc54ea926c5aa06 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Wed, 23 Apr 2025 07:58:02 -0500 Subject: [PATCH 4/4] fix table formatting Signed-off-by: Andrew Brandt --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 578e552..e9fde5a 100644 --- a/README.md +++ b/README.md @@ -40,15 +40,15 @@ fine-grained token with the following permissions: ## 📦 Inputs -| Name | Description | Required | Default | -|------------------------------------|------------------------------------------------------------------------|----------|---------| -| `token` | GitHub Personal Access Token (Fine-Grained with: Organization custom properties `Read`, Repository contents `Read and Write` scope) | ✅ Yes | — | -| `overwrite-existing-file` | Boolean for choosing to overwrite `repo-properties.json`, if it exists | 🟥 No | `false` | -| `dry-run-enabled` | Flag to dry-run the script, will not commit in repo. | 🟥 No | `false` | -| `commit-author-name` | Author Name on the commit that will be created | ✅ Yes | - | -| `commit-author-email` | Author Email on the commit that will be created | ✅ Yes | - | -| `commit-author-gpg-key-contents` | GPG Key for the commit that will be created (must match the `email`) | ✅ Yes | - | -| `commit-author-gpg-key-passphrase` | GPG Key Passphrase for the key to sign the commit that will be created | ✅ Yes | - | +| Name | Description | Required | Default | +|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|----------|---------| +| `token` | GitHub Personal Access Token (Fine-Grained with: Organization custom properties `Read`, Repository contents `Read and Write` scope) | ✅ Yes | — | +| `overwrite-existing-file` | Boolean for choosing to overwrite `repo-properties.json`, if it exists | 🟥 No | `false` | +| `dry-run-enabled` | Flag to dry-run the script, will not commit in repo. | 🟥 No | `false` | +| `commit-author-name` | Author Name on the commit that will be created | ✅ Yes | - | +| `commit-author-email` | Author Email on the commit that will be created | ✅ Yes | - | +| `commit-author-gpg-key-contents` | GPG Key for the commit that will be created (must match the `email`) | ✅ Yes | - | +| `commit-author-gpg-key-passphrase` | GPG Key Passphrase for the key to sign the commit that will be created | ✅ Yes | - | ---