From 7d7a103a1e16380e997aa75150ac9e3b833367ef Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Tue, 15 Apr 2025 20:12:46 -0500 Subject: [PATCH 01/48] ci: create action to read all custom properties in all repos Signed-off-by: Andrew Brandt --- action.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 action.yaml diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..60075ed --- /dev/null +++ b/action.yaml @@ -0,0 +1,18 @@ +name: 'Read Custom Properties of All Repos in Organization' +description: 'Read all the custom properties and values of all repos in an organization' +author: 'Andrew Brandt ' +organization: 'PandasWhoCode' +branding: + icon: 'check-circle' + color: 'black' + +inputs: + token: + description: 'Personal Access Token' + required: true + +runs: + using: "composite" + steps: + - name: List all repos in the Org + shell: bash From ec89b4eb42ce4cac60454d1589db25984f86fa38 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 08:08:25 -0500 Subject: [PATCH 02/48] pull full list of repo names and output to text file Signed-off-by: Andrew Brandt --- action.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 60075ed..a05bdf8 100644 --- a/action.yaml +++ b/action.yaml @@ -14,5 +14,12 @@ inputs: runs: using: "composite" steps: - - name: List all repos in the Org + - name: List all repos in org shell: bash + run: | + echo "Fetching repos for organization: ${{ inputs.org }}" + curl -s -H "Authorization: token ${{ inputs.token }}" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/orgs/${{ inputs.org }}/repos?per_page=100" | + jq -r '.[].full_name' > repo-list.txt + echo "Repos written to repo-list.txt" From 45b7b9b6054a39bf1648a60f2b60de705c5ad954 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 08:13:02 -0500 Subject: [PATCH 03/48] add org name processing Signed-off-by: Andrew Brandt --- action.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/action.yaml b/action.yaml index a05bdf8..7fd584c 100644 --- a/action.yaml +++ b/action.yaml @@ -14,9 +14,21 @@ inputs: runs: using: "composite" steps: + + - name: Install yq (mikefarah's version) + shell: bash + run: | + sudo wget --quiet https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq + sudo chmod +x /usr/bin/yq + yq --version # confirm installed + + + - name: List all repos in org shell: bash run: | + ORG_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f1) + echo "Org name is: ${ORG_NAME}" echo "Fetching repos for organization: ${{ inputs.org }}" curl -s -H "Authorization: token ${{ inputs.token }}" \ -H "Accept: application/vnd.github+json" \ From 888d3ae400dc3884b7ca69788396671e06fc688c Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 08:15:17 -0500 Subject: [PATCH 04/48] switch to gh api Signed-off-by: Andrew Brandt --- action.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/action.yaml b/action.yaml index 7fd584c..35bb15b 100644 --- a/action.yaml +++ b/action.yaml @@ -30,8 +30,5 @@ runs: ORG_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f1) echo "Org name is: ${ORG_NAME}" echo "Fetching repos for organization: ${{ inputs.org }}" - curl -s -H "Authorization: token ${{ inputs.token }}" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/orgs/${{ inputs.org }}/repos?per_page=100" | - jq -r '.[].full_name' > repo-list.txt + gh api --paginate "orgs/$ORG_NAME/repos" --jq '.[].full_name' > repo-list.txt echo "Repos written to repo-list.txt" From 9566a7ab7ce09ead990cfcb7c836ae9771e89f3f Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 08:16:17 -0500 Subject: [PATCH 05/48] add token Signed-off-by: Andrew Brandt --- action.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yaml b/action.yaml index 35bb15b..542879a 100644 --- a/action.yaml +++ b/action.yaml @@ -26,6 +26,8 @@ runs: - name: List all repos in org shell: bash + env: + GH_TOKEN: ${{ inputs.token }} run: | ORG_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f1) echo "Org name is: ${ORG_NAME}" From edc82c273c8e025a6f3163580d3774a5ba0baee5 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 08:18:27 -0500 Subject: [PATCH 06/48] add printout Signed-off-by: Andrew Brandt --- action.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 542879a..b5bb27b 100644 --- a/action.yaml +++ b/action.yaml @@ -31,6 +31,13 @@ runs: run: | ORG_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f1) echo "Org name is: ${ORG_NAME}" + cat "${ORG_NAME}" > repo-list.txt echo "Fetching repos for organization: ${{ inputs.org }}" - gh api --paginate "orgs/$ORG_NAME/repos" --jq '.[].full_name' > repo-list.txt + gh api --paginate "orgs/$ORG_NAME/repos" --jq '.[].full_name' >> repo-list.txt echo "Repos written to repo-list.txt" + + - name: Print out all repos in file + shell: bash + run: | + echo "Full list of repos in org:" + cat repo-list.txt From 27d3fcfd234c3a9146f406982a438e2b7d33bf2c Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 08:19:53 -0500 Subject: [PATCH 07/48] send org name to a new file Signed-off-by: Andrew Brandt --- action.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index b5bb27b..0360ca0 100644 --- a/action.yaml +++ b/action.yaml @@ -31,13 +31,15 @@ runs: run: | ORG_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f1) echo "Org name is: ${ORG_NAME}" - cat "${ORG_NAME}" > repo-list.txt + cat "${ORG_NAME}" > org-name.txt echo "Fetching repos for organization: ${{ inputs.org }}" - gh api --paginate "orgs/$ORG_NAME/repos" --jq '.[].full_name' >> repo-list.txt + gh api --paginate "orgs/$ORG_NAME/repos" --jq '.[].full_name' > repo-list.txt echo "Repos written to repo-list.txt" - name: Print out all repos in file shell: bash run: | + echo "Org name is:" + cat org-name.txt echo "Full list of repos in org:" cat repo-list.txt From 4abcac541bfb849b0bf5763bf5dcf84ed681d1e3 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 08:21:16 -0500 Subject: [PATCH 08/48] fix error with cat Signed-off-by: Andrew Brandt --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 0360ca0..775b45f 100644 --- a/action.yaml +++ b/action.yaml @@ -31,7 +31,7 @@ runs: run: | ORG_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f1) echo "Org name is: ${ORG_NAME}" - cat "${ORG_NAME}" > org-name.txt + echo "${ORG_NAME}" > org-name.txt echo "Fetching repos for organization: ${{ inputs.org }}" gh api --paginate "orgs/$ORG_NAME/repos" --jq '.[].full_name' > repo-list.txt echo "Repos written to repo-list.txt" From 54926afd7e99f6f9888ac4dfb381104899f100c8 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 08:23:03 -0500 Subject: [PATCH 09/48] switch to only repo name instead of full name Signed-off-by: Andrew Brandt --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 775b45f..49121e9 100644 --- a/action.yaml +++ b/action.yaml @@ -33,7 +33,7 @@ runs: echo "Org name is: ${ORG_NAME}" echo "${ORG_NAME}" > org-name.txt echo "Fetching repos for organization: ${{ inputs.org }}" - gh api --paginate "orgs/$ORG_NAME/repos" --jq '.[].full_name' > repo-list.txt + gh api --paginate "orgs/$ORG_NAME/repos" --jq '.[].name' > repo-list.txt echo "Repos written to repo-list.txt" - name: Print out all repos in file From d9841150bd2cd4a569876382daee4a6180a6ef8c Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 08:29:34 -0500 Subject: [PATCH 10/48] read props from all repos Signed-off-by: Andrew Brandt --- action.yaml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/action.yaml b/action.yaml index 49121e9..c3201af 100644 --- a/action.yaml +++ b/action.yaml @@ -43,3 +43,36 @@ runs: cat org-name.txt echo "Full list of repos in org:" cat repo-list.txt + + - name: Fetch custom properties for each repo + shell: bash + env: + GH_TOKEN: ${{ inputs.token }} + run: | + ORG_NAME="${GITHUB_REPOSITORY%%/*}" + echo "Fetching custom properties for repos in org: ${ORG_NAME}" + + echo "{" > repo-properties.json + FIRST=1 + while IFS= read -r REPO_NAME; do + echo "Getting properties for ${REPO_NAME}..." + RESPONSE=$(gh api "repos/${ORG_NAME}/${REPO_NAME}/properties/values" || echo "{}") + + # If not the first, prepend a comma to separate JSON entries + if [ "$FIRST" -eq 0 ]; then + echo "," >> repo-properties.json + fi + FIRST=0 + + # Output as "repo-name": { ...props... } + echo "\"${REPO_NAME}\": $RESPONSE" >> repo-properties.json + done < repo-list.txt + echo "}" >> repo-properties.json + + echo "Custom properties written to repo-properties.json" + + - name: Print out the full repo-properties.json file + shell: bash + run: | + echo "Full repo-properties.json file is:" + cat repo-properties.json From 9967106efab61398efebfc5e45fce9398b12d948 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 08:48:02 -0500 Subject: [PATCH 11/48] format the JSON output as YAML Signed-off-by: Andrew Brandt --- action.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/action.yaml b/action.yaml index c3201af..fd2e2b5 100644 --- a/action.yaml +++ b/action.yaml @@ -76,3 +76,24 @@ runs: run: | echo "Full repo-properties.json file is:" cat repo-properties.json + + - name: Convert JSON to formatted YAML + shell: bash + run: | + ORG_NAME=$(cat org-name.txt) + echo "org: $ORG_NAME" > repo-properties.yaml + echo "repositories:" >> repo-properties.yaml + + jq -r 'to_entries[] | + .key as $repoName | + " - name: \($repoName)\n last-date-modified: \"\"\n" + + (.value | map(" \(.property_name): \"\(.value)\"") | join("\n"))' repo-properties.json >> repo-properties.yaml + + echo "YAML written to repo-properties.yaml" + + - name: Print out the repo-properties.yaml + shell: bash + run: | + echo "Full repo-properties.yaml file is:" + cat repo-properties.yaml + From a5438e23be949187d9a8b9fd60f35709f29abdb0 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 09:02:06 -0500 Subject: [PATCH 12/48] clean up the conversion step Signed-off-by: Andrew Brandt --- action.yaml | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/action.yaml b/action.yaml index fd2e2b5..5031c41 100644 --- a/action.yaml +++ b/action.yaml @@ -77,18 +77,32 @@ runs: echo "Full repo-properties.json file is:" cat repo-properties.json - - name: Convert JSON to formatted YAML + - name: Convert repo properties JSON to YAML shell: bash run: | ORG_NAME=$(cat org-name.txt) - echo "org: $ORG_NAME" > repo-properties.yaml - echo "repositories:" >> repo-properties.yaml - - jq -r 'to_entries[] | - .key as $repoName | - " - name: \($repoName)\n last-date-modified: \"\"\n" + - (.value | map(" \(.property_name): \"\(.value)\"") | join("\n"))' repo-properties.json >> repo-properties.yaml - + + { + echo "org: $ORG_NAME" + echo "repositories:" + jq -r ' + to_entries[] | + .key as $repoName | + ( + " - name: \($repoName)" + + ( + .value + | map(select(.value != "")) # skip blank-value fields + | if length > 0 then + "\n" + map(" \(.property_name): \"\(.value)\"") | join("\n") + else + "" + end + ) + ) + ' repo-properties.json + } > repo-properties.yaml + echo "YAML written to repo-properties.yaml" - name: Print out the repo-properties.yaml From 146af09fc4ad35b51ed26adb883dcd7f2bce0341 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 09:04:47 -0500 Subject: [PATCH 13/48] fix error Signed-off-by: Andrew Brandt --- action.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 5031c41..02abc2c 100644 --- a/action.yaml +++ b/action.yaml @@ -92,9 +92,9 @@ runs: " - name: \($repoName)" + ( .value - | map(select(.value != "")) # skip blank-value fields + | map(select(.value != "")) | if length > 0 then - "\n" + map(" \(.property_name): \"\(.value)\"") | join("\n") + "\n" + (map(" \(.property_name): \"\(.value)\"") | join("\n")) else "" end @@ -104,6 +104,7 @@ runs: } > repo-properties.yaml echo "YAML written to repo-properties.yaml" + - name: Print out the repo-properties.yaml shell: bash From 1410cb837247f81aec128f6fa05314cbb1618d27 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 09:33:41 -0500 Subject: [PATCH 14/48] add blank template as input Signed-off-by: Andrew Brandt --- action.yaml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/action.yaml b/action.yaml index 02abc2c..1e1f4cf 100644 --- a/action.yaml +++ b/action.yaml @@ -10,6 +10,9 @@ inputs: token: description: 'Personal Access Token' required: true + template: + description: 'Template for Custom Property Fields' + required: false runs: using: "composite" @@ -77,7 +80,7 @@ runs: echo "Full repo-properties.json file is:" cat repo-properties.json - - name: Convert repo properties JSON to YAML + - name: Convert repo properties to YAML using template shell: bash run: | ORG_NAME=$(cat org-name.txt) @@ -85,19 +88,23 @@ runs: { echo "org: $ORG_NAME" echo "repositories:" - jq -r ' + jq -r --argfile template ${{ inputs.template }} ' to_entries[] | .key as $repoName | + .value as $props | + $template as $fields | ( - " - name: \($repoName)" + + " - name: \($repoName)\n" + ( - .value - | map(select(.value != "")) - | if length > 0 then - "\n" + (map(" \(.property_name): \"\(.value)\"") | join("\n")) - else - "" - end + $fields + | map( + . as $key | + ( + ($props | map({(.property_name): .value}) | add)[$key] // "" + | " \($key): \"\(.)\"" + ) + ) + | join("\n") ) ) ' repo-properties.json @@ -105,6 +112,7 @@ runs: echo "YAML written to repo-properties.yaml" + - name: Print out the repo-properties.yaml shell: bash From 086fc5d22e100162b3a8d0da8f4f7dd4ad3be2e6 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 09:35:20 -0500 Subject: [PATCH 15/48] cat the template file Signed-off-by: Andrew Brandt --- action.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/action.yaml b/action.yaml index 1e1f4cf..a30a8f1 100644 --- a/action.yaml +++ b/action.yaml @@ -80,6 +80,12 @@ runs: echo "Full repo-properties.json file is:" cat repo-properties.json + - name: Confirm the template file exists + shell: bash + run: | + echo "The template file for JSON output is:" + cat ${{ inputs.template }} + - name: Convert repo properties to YAML using template shell: bash run: | From 9611da222b5712ff87bfa3b6c88d7acda5868bdc Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 09:42:32 -0500 Subject: [PATCH 16/48] switch how the template file is read in Signed-off-by: Andrew Brandt --- action.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index a30a8f1..21b2f27 100644 --- a/action.yaml +++ b/action.yaml @@ -91,14 +91,15 @@ runs: run: | ORG_NAME=$(cat org-name.txt) + TEMPLATE=$(cat ${{ inputs.template }}) + { echo "org: $ORG_NAME" echo "repositories:" - jq -r --argfile template ${{ inputs.template }} ' + jq -r --argjson fields "$TEMPLATE" ' to_entries[] | .key as $repoName | .value as $props | - $template as $fields | ( " - name: \($repoName)\n" + ( @@ -119,6 +120,7 @@ runs: echo "YAML written to repo-properties.yaml" + - name: Print out the repo-properties.yaml shell: bash From c638f58bcdd54b83678237069aa330a1b2d88ca1 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 09:54:39 -0500 Subject: [PATCH 17/48] add overwrite existing repo properties file input Signed-off-by: Andrew Brandt --- action.yaml | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/action.yaml b/action.yaml index 21b2f27..f382cc5 100644 --- a/action.yaml +++ b/action.yaml @@ -13,6 +13,9 @@ inputs: template: description: 'Template for Custom Property Fields' required: false + overwrite-existing-file: + description: 'Overwrite existing repo-properties.yaml with read values' + required: false runs: using: "composite" @@ -55,7 +58,7 @@ runs: ORG_NAME="${GITHUB_REPOSITORY%%/*}" echo "Fetching custom properties for repos in org: ${ORG_NAME}" - echo "{" > repo-properties.json + echo "{" > read-repo-properties.json FIRST=1 while IFS= read -r REPO_NAME; do echo "Getting properties for ${REPO_NAME}..." @@ -63,22 +66,22 @@ runs: # If not the first, prepend a comma to separate JSON entries if [ "$FIRST" -eq 0 ]; then - echo "," >> repo-properties.json + echo "," >> read-repo-properties.json fi FIRST=0 # Output as "repo-name": { ...props... } - echo "\"${REPO_NAME}\": $RESPONSE" >> repo-properties.json + echo "\"${REPO_NAME}\": $RESPONSE" >> read-repo-properties.json done < repo-list.txt - echo "}" >> repo-properties.json + echo "}" >> read-repo-properties.json - echo "Custom properties written to repo-properties.json" + echo "Custom properties written to read-repo-properties.json" - - name: Print out the full repo-properties.json file + - name: Print out the full read-repo-properties.json file shell: bash run: | - echo "Full repo-properties.json file is:" - cat repo-properties.json + echo "Full read-repo-properties.json file is:" + cat read-repo-properties.json - name: Confirm the template file exists shell: bash @@ -114,17 +117,21 @@ runs: | join("\n") ) ) - ' repo-properties.json - } > repo-properties.yaml + ' read-repo-properties.json + } > read-repo-properties.yaml - echo "YAML written to repo-properties.yaml" - - - + echo "YAML written to read-repo-properties.yaml" + + - name: Print out the read-repo-properties.yaml + shell: bash + run: | + echo "Full read-repo-properties.yaml file is:" + cat read-repo-properties.yaml - - name: Print out the repo-properties.yaml + - name: Overwrite existing file (if applicable) + if: inputs.overwrite-existing-file == true shell: bash run: | - echo "Full repo-properties.yaml file is:" - cat repo-properties.yaml + echo "Overwriting existing repo-properties.yaml" + mv read-repo-properties.yaml repo-properties.yaml From 9767ba1a4624d22ed6c6c56cb9f579d03c04ccf1 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Thu, 17 Apr 2025 09:55:39 -0500 Subject: [PATCH 18/48] add default behavior Signed-off-by: Andrew Brandt --- action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yaml b/action.yaml index f382cc5..c26d756 100644 --- a/action.yaml +++ b/action.yaml @@ -15,6 +15,7 @@ inputs: required: false overwrite-existing-file: description: 'Overwrite existing repo-properties.yaml with read values' + default: false required: false runs: From 77479098f377e9e1b84a8d3d16569e4dcdda6337 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 12:29:51 -0500 Subject: [PATCH 19/48] add overwrite and commit steps Signed-off-by: Andrew Brandt --- action.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index c26d756..e061ad0 100644 --- a/action.yaml +++ b/action.yaml @@ -17,6 +17,10 @@ inputs: description: 'Overwrite existing repo-properties.yaml with read values' default: false required: false + commit-changes: + description: 'Commit values read to the repo' + default: false + required: false runs: using: "composite" @@ -28,8 +32,6 @@ runs: sudo wget --quiet https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq sudo chmod +x /usr/bin/yq yq --version # confirm installed - - - name: List all repos in org shell: bash @@ -130,9 +132,20 @@ runs: cat read-repo-properties.yaml - name: Overwrite existing file (if applicable) - if: inputs.overwrite-existing-file == true + if: ${{ inputs.overwrite-existing-file == true }} shell: bash run: | echo "Overwriting existing repo-properties.yaml" mv read-repo-properties.yaml repo-properties.yaml + - name: Commit values read to repo-properties.yaml + if: ${{ inputs.commit-changes == true }} + shell: bash + uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 + with: + cwd: "." + author_name: ${{ secrets.SVCS_GIT_USER_NAME }} + author_email: ${{ secrets.SVCS_GIT_USER_EMAIL }} + commit: --signoff + message: "chore: commit repo custom properties to properties file" + From d277a6ea837804679f61bb671302c2b742b8e5df Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 12:43:19 -0500 Subject: [PATCH 20/48] remove add and commit step Signed-off-by: Andrew Brandt --- action.yaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/action.yaml b/action.yaml index e061ad0..fd57bbd 100644 --- a/action.yaml +++ b/action.yaml @@ -138,14 +138,3 @@ runs: echo "Overwriting existing repo-properties.yaml" mv read-repo-properties.yaml repo-properties.yaml - - name: Commit values read to repo-properties.yaml - if: ${{ inputs.commit-changes == true }} - shell: bash - uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 - with: - cwd: "." - author_name: ${{ secrets.SVCS_GIT_USER_NAME }} - author_email: ${{ secrets.SVCS_GIT_USER_EMAIL }} - commit: --signoff - message: "chore: commit repo custom properties to properties file" - From 92be387caddc73b3644b013d040b0b5579bda1c9 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 12:44:49 -0500 Subject: [PATCH 21/48] add the commit step Signed-off-by: Andrew Brandt --- action.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/action.yaml b/action.yaml index fd57bbd..a8821e3 100644 --- a/action.yaml +++ b/action.yaml @@ -138,3 +138,13 @@ runs: echo "Overwriting existing repo-properties.yaml" mv read-repo-properties.yaml repo-properties.yaml + - name: Commit values to repo-properties.yaml + if: ${{ inputs.commit-changes == true }} + shell: bash + uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 + with: + cwd: "." + author_name: ${{ secrets.SVCS_GIT_USER_NAME }} + author_email: ${{ secrets.SVCS_GIT_USER_EMAIL }} + commit: --signoff + message: "chore: commit repo custom properties to properties file" From 02001748abc95daa65da3b80e695ac1b09ed7d84 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 12:46:21 -0500 Subject: [PATCH 22/48] remove the add and commit step Signed-off-by: Andrew Brandt --- action.yaml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/action.yaml b/action.yaml index a8821e3..2c3141f 100644 --- a/action.yaml +++ b/action.yaml @@ -135,16 +135,8 @@ runs: if: ${{ inputs.overwrite-existing-file == true }} shell: bash run: | + echo "We are going to overwrite repo-properties.yaml echo "Overwriting existing repo-properties.yaml" mv read-repo-properties.yaml repo-properties.yaml - - name: Commit values to repo-properties.yaml - if: ${{ inputs.commit-changes == true }} - shell: bash - uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 - with: - cwd: "." - author_name: ${{ secrets.SVCS_GIT_USER_NAME }} - author_email: ${{ secrets.SVCS_GIT_USER_EMAIL }} - commit: --signoff - message: "chore: commit repo custom properties to properties file" + From 40aa07d514fc4aea98c0e290e70d73f9a8916f08 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 12:49:30 -0500 Subject: [PATCH 23/48] add check to the input value Signed-off-by: Andrew Brandt --- action.yaml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/action.yaml b/action.yaml index 2c3141f..7b253ce 100644 --- a/action.yaml +++ b/action.yaml @@ -132,11 +132,22 @@ runs: cat read-repo-properties.yaml - name: Overwrite existing file (if applicable) - if: ${{ inputs.overwrite-existing-file == true }} shell: bash run: | - echo "We are going to overwrite repo-properties.yaml - echo "Overwriting existing repo-properties.yaml" - mv read-repo-properties.yaml repo-properties.yaml + echo "We are going to overwrite repo-properties.yaml" + echo "Here is the current value of inputs.overwrite-existing-file" + echo ${{ inputs.overwrite-existing-file }} +# echo "Overwriting existing repo-properties.yaml" +# mv read-repo-properties.yaml repo-properties.yaml +# +# - name: Commit values to repo-properties.yaml +# if: ${{ inputs.commit-changes == true }} +# shell: bash +# uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 +# with: +# cwd: "." +# author_name: ${{ secrets.SVCS_GIT_USER_NAME }} +# author_email: ${{ secrets.SVCS_GIT_USER_EMAIL }} +# commit: --signoff +# message: "chore: commit repo custom properties to properties file" - From fba7e134449de9193487b66f1f499a61f34705ba Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 12:50:36 -0500 Subject: [PATCH 24/48] add if-check Signed-off-by: Andrew Brandt --- action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yaml b/action.yaml index 7b253ce..e955925 100644 --- a/action.yaml +++ b/action.yaml @@ -132,6 +132,7 @@ runs: cat read-repo-properties.yaml - name: Overwrite existing file (if applicable) + if: ${{ inputs.overwrite-existing-file == true }} shell: bash run: | echo "We are going to overwrite repo-properties.yaml" From 15e8271dafaabf03e1db2e67183e09704ce0b178 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 12:57:20 -0500 Subject: [PATCH 25/48] change the string deliminators for the input value Signed-off-by: Andrew Brandt --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index e955925..2743a0d 100644 --- a/action.yaml +++ b/action.yaml @@ -132,7 +132,7 @@ runs: cat read-repo-properties.yaml - name: Overwrite existing file (if applicable) - if: ${{ inputs.overwrite-existing-file == true }} + if: ${{ inputs.overwrite-existing-file == 'true' }} shell: bash run: | echo "We are going to overwrite repo-properties.yaml" From 97742ad4e950cb7acf5e740ed454c6f47bcd9b67 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 12:58:26 -0500 Subject: [PATCH 26/48] add the overwrite step Signed-off-by: Andrew Brandt --- action.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/action.yaml b/action.yaml index 2743a0d..ca750c4 100644 --- a/action.yaml +++ b/action.yaml @@ -136,10 +136,8 @@ runs: shell: bash run: | echo "We are going to overwrite repo-properties.yaml" - echo "Here is the current value of inputs.overwrite-existing-file" - echo ${{ inputs.overwrite-existing-file }} -# echo "Overwriting existing repo-properties.yaml" -# mv read-repo-properties.yaml repo-properties.yaml + echo "Overwriting existing repo-properties.yaml" + mv read-repo-properties.yaml repo-properties.yaml # # - name: Commit values to repo-properties.yaml # if: ${{ inputs.commit-changes == true }} From f22f5ba140301ba6f52bd3db04a962e2477a7e06 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 13:08:14 -0500 Subject: [PATCH 27/48] add commit step Signed-off-by: Andrew Brandt --- action.yaml | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/action.yaml b/action.yaml index ca750c4..d43eef5 100644 --- a/action.yaml +++ b/action.yaml @@ -16,11 +16,19 @@ inputs: overwrite-existing-file: description: 'Overwrite existing repo-properties.yaml with read values' default: false + type: boolean required: false commit-changes: - description: 'Commit values read to the repo' + description: 'Commit values read to the properties file' default: false + type: boolean required: false + commit-author-name: + description: 'Author of commit name:' + required: true + commit-author-email: + description: 'Author of commit email address:' + required: true runs: using: "composite" @@ -135,18 +143,18 @@ runs: if: ${{ inputs.overwrite-existing-file == 'true' }} shell: bash run: | - echo "We are going to overwrite repo-properties.yaml" echo "Overwriting existing repo-properties.yaml" mv read-repo-properties.yaml repo-properties.yaml -# -# - name: Commit values to repo-properties.yaml -# if: ${{ inputs.commit-changes == true }} -# shell: bash -# uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 -# with: -# cwd: "." -# author_name: ${{ secrets.SVCS_GIT_USER_NAME }} -# author_email: ${{ secrets.SVCS_GIT_USER_EMAIL }} -# commit: --signoff -# message: "chore: commit repo custom properties to properties file" + echo "Overwrite complete" + + - name: Commit values to repo-properties.yaml + if: ${{ inputs.commit-changes == 'true' }} + shell: bash + uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 + with: + cwd: "." + author_name: ${{ inputs.commit-author-name }} + author_email: ${{ inputs.commit-author-email }} + commit: --signoff + message: "chore: commit repo custom properties to properties file" From 2c95a76d3d403af32f3dbfa1f0c5569d5f60717e Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 13:08:46 -0500 Subject: [PATCH 28/48] add push true Signed-off-by: Andrew Brandt --- action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yaml b/action.yaml index d43eef5..72cb591 100644 --- a/action.yaml +++ b/action.yaml @@ -157,4 +157,5 @@ runs: author_email: ${{ inputs.commit-author-email }} commit: --signoff message: "chore: commit repo custom properties to properties file" + push: true From 1416295b5dcbf8a9af14ab747567d02773504f0a Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 13:11:30 -0500 Subject: [PATCH 29/48] remove boolean types from input Signed-off-by: Andrew Brandt --- action.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/action.yaml b/action.yaml index 72cb591..81708f5 100644 --- a/action.yaml +++ b/action.yaml @@ -16,12 +16,10 @@ inputs: overwrite-existing-file: description: 'Overwrite existing repo-properties.yaml with read values' default: false - type: boolean required: false commit-changes: description: 'Commit values read to the properties file' default: false - type: boolean required: false commit-author-name: description: 'Author of commit name:' From 3d10014ce5f3fb3f1250542fe6833aab45033ebb Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 13:12:36 -0500 Subject: [PATCH 30/48] remove commit step Signed-off-by: Andrew Brandt --- action.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/action.yaml b/action.yaml index 81708f5..d7a4dee 100644 --- a/action.yaml +++ b/action.yaml @@ -145,15 +145,15 @@ runs: mv read-repo-properties.yaml repo-properties.yaml echo "Overwrite complete" - - name: Commit values to repo-properties.yaml - if: ${{ inputs.commit-changes == 'true' }} - shell: bash - uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 - with: - cwd: "." - author_name: ${{ inputs.commit-author-name }} - author_email: ${{ inputs.commit-author-email }} - commit: --signoff - message: "chore: commit repo custom properties to properties file" - push: true - +# - name: Commit values to repo-properties.yaml +# if: ${{ inputs.commit-changes == 'true' }} +# shell: bash +# uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 +# with: +# cwd: "." +# author_name: ${{ inputs.commit-author-name }} +# author_email: ${{ inputs.commit-author-email }} +# commit: --signoff +# message: "chore: commit repo custom properties to properties file" +# push: true +# From a0122d55d8606968d4d3c88ff91a756519e830c9 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 13:13:32 -0500 Subject: [PATCH 31/48] add boolean types back in Signed-off-by: Andrew Brandt --- action.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yaml b/action.yaml index d7a4dee..2072a23 100644 --- a/action.yaml +++ b/action.yaml @@ -15,10 +15,12 @@ inputs: required: false overwrite-existing-file: description: 'Overwrite existing repo-properties.yaml with read values' + type: boolean default: false required: false commit-changes: description: 'Commit values read to the properties file' + type: boolean default: false required: false commit-author-name: From 6a05930465277e92ea715d237a800be54b7f8366 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 13:20:42 -0500 Subject: [PATCH 32/48] add the commit step back in Signed-off-by: Andrew Brandt --- action.yaml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/action.yaml b/action.yaml index 2072a23..917e508 100644 --- a/action.yaml +++ b/action.yaml @@ -147,15 +147,14 @@ runs: mv read-repo-properties.yaml repo-properties.yaml echo "Overwrite complete" -# - name: Commit values to repo-properties.yaml -# if: ${{ inputs.commit-changes == 'true' }} -# shell: bash -# uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 -# with: -# cwd: "." -# author_name: ${{ inputs.commit-author-name }} -# author_email: ${{ inputs.commit-author-email }} -# commit: --signoff -# message: "chore: commit repo custom properties to properties file" -# push: true -# + - name: Commit values to repo-properties.yaml + if: ${{ inputs.commit-changes == 'true' }} + shell: bash + uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 + with: + cwd: "." + author_name: ${{ inputs.commit-author-name }} + author_email: ${{ inputs.commit-author-email }} + message: "chore: commit repo custom properties to properties file" + push: true + From 13bcdbe00c6e8e9da8faa5931f1d71688fa216e9 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 13:26:08 -0500 Subject: [PATCH 33/48] switch to doing the commit manually Signed-off-by: Andrew Brandt --- action.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/action.yaml b/action.yaml index 917e508..395f706 100644 --- a/action.yaml +++ b/action.yaml @@ -150,11 +150,10 @@ runs: - name: Commit values to repo-properties.yaml if: ${{ inputs.commit-changes == 'true' }} shell: bash - uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 - with: - cwd: "." - author_name: ${{ inputs.commit-author-name }} - author_email: ${{ inputs.commit-author-email }} - message: "chore: commit repo custom properties to properties file" - push: true + run: | + git config user.name "${{ inputs.commit-author-name }}" + git config user.email "${{ inputs.commit-author-email }}" + git add repo-properties.yaml + git commit -m "chore: commit repo custom properties to properties file" || echo "Nothing to commit" + git push From be8c9e80226e1c88aff9ca9fe362cc47f3b2e7e8 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 14:21:04 -0500 Subject: [PATCH 34/48] read the props to build up the template file Signed-off-by: Andrew Brandt --- action.yaml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 395f706..38a3cde 100644 --- a/action.yaml +++ b/action.yaml @@ -41,6 +41,19 @@ runs: sudo chmod +x /usr/bin/yq yq --version # confirm installed + - name: Extract property names into a JSON array + shell: bash + env: + GH_TOKEN: ${{ inputs.token }} # or use your PAT if needed + run: | + ORG=$(cat org-name.txt) + echo "Fetching property schema for org: $ORG" + + gh api --paginate "orgs/$ORG/properties/schema" \ + | jq 'map(.property_name)' > property-names.json + + echo "Property names written to property-names.json" + - name: List all repos in org shell: bash env: @@ -98,14 +111,14 @@ runs: shell: bash run: | echo "The template file for JSON output is:" - cat ${{ inputs.template }} + cat property-names.json - name: Convert repo properties to YAML using template shell: bash run: | ORG_NAME=$(cat org-name.txt) - TEMPLATE=$(cat ${{ inputs.template }}) + TEMPLATE=$(cat property-names.json) { echo "org: $ORG_NAME" From 299a9dc80fecc7a7103e02f927140621060c9c9d Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 14:22:36 -0500 Subject: [PATCH 35/48] add access to org name file Signed-off-by: Andrew Brandt --- action.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/action.yaml b/action.yaml index 38a3cde..a75c33b 100644 --- a/action.yaml +++ b/action.yaml @@ -41,6 +41,18 @@ runs: sudo chmod +x /usr/bin/yq yq --version # confirm installed + - name: List all repos in org + shell: bash + env: + GH_TOKEN: ${{ inputs.token }} + run: | + ORG_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f1) + echo "Org name is: ${ORG_NAME}" + echo "${ORG_NAME}" > org-name.txt + echo "Fetching repos for organization: ${{ inputs.org }}" + gh api --paginate "orgs/$ORG_NAME/repos" --jq '.[].name' > repo-list.txt + echo "Repos written to repo-list.txt" + - name: Extract property names into a JSON array shell: bash env: @@ -54,18 +66,6 @@ runs: echo "Property names written to property-names.json" - - name: List all repos in org - shell: bash - env: - GH_TOKEN: ${{ inputs.token }} - run: | - ORG_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f1) - echo "Org name is: ${ORG_NAME}" - echo "${ORG_NAME}" > org-name.txt - echo "Fetching repos for organization: ${{ inputs.org }}" - gh api --paginate "orgs/$ORG_NAME/repos" --jq '.[].name' > repo-list.txt - echo "Repos written to repo-list.txt" - - name: Print out all repos in file shell: bash run: | From fe1d4b793466795436977fa5ef6ad25c0f3e8ff3 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 14:50:40 -0500 Subject: [PATCH 36/48] remove the template field Signed-off-by: Andrew Brandt --- action.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/action.yaml b/action.yaml index a75c33b..c94c2d7 100644 --- a/action.yaml +++ b/action.yaml @@ -10,9 +10,6 @@ inputs: token: description: 'Personal Access Token' required: true - template: - description: 'Template for Custom Property Fields' - required: false overwrite-existing-file: description: 'Overwrite existing repo-properties.yaml with read values' type: boolean From 70e08bd7b01b31a464ee871dde5cf8e80e823157 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 14:54:30 -0500 Subject: [PATCH 37/48] switch to dry-run-enabled flag Signed-off-by: Andrew Brandt --- action.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index c94c2d7..65e96ea 100644 --- a/action.yaml +++ b/action.yaml @@ -15,8 +15,8 @@ inputs: type: boolean default: false required: false - commit-changes: - description: 'Commit values read to the properties file' + dry-run-enabled: + description: 'Dry run the script' type: boolean default: false required: false @@ -158,7 +158,7 @@ runs: echo "Overwrite complete" - name: Commit values to repo-properties.yaml - if: ${{ inputs.commit-changes == 'true' }} + if: ${{ inputs.dry-run-enabled != 'true' }} shell: bash run: | git config user.name "${{ inputs.commit-author-name }}" From b8cba98881ef254b9f3ab64db2e41a549d7cc9f9 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 15:11:05 -0500 Subject: [PATCH 38/48] cleanup script, no major changes Signed-off-by: Andrew Brandt --- action.yaml | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/action.yaml b/action.yaml index 65e96ea..d1f9e88 100644 --- a/action.yaml +++ b/action.yaml @@ -1,6 +1,6 @@ -name: 'Read Custom Properties of All Repos in Organization' +name: 'Read Custom Properties of All Repos in an Organization' description: 'Read all the custom properties and values of all repos in an organization' -author: 'Andrew Brandt ' +author: 'Andrew Brandt ' organization: 'PandasWhoCode' branding: icon: 'check-circle' @@ -30,7 +30,6 @@ inputs: runs: using: "composite" steps: - - name: Install yq (mikefarah's version) shell: bash run: | @@ -50,26 +49,23 @@ runs: gh api --paginate "orgs/$ORG_NAME/repos" --jq '.[].name' > repo-list.txt echo "Repos written to repo-list.txt" - - name: Extract property names into a JSON array + - name: Extract property names into a JSON file shell: bash env: GH_TOKEN: ${{ inputs.token }} # or use your PAT if needed run: | ORG=$(cat org-name.txt) echo "Fetching property schema for org: $ORG" - - gh api --paginate "orgs/$ORG/properties/schema" \ - | jq 'map(.property_name)' > property-names.json - + gh api --paginate "orgs/$ORG/properties/schema" | jq 'map(.property_name)' > property-names.json echo "Property names written to property-names.json" - - name: Print out all repos in file - shell: bash - run: | - echo "Org name is:" - cat org-name.txt - echo "Full list of repos in org:" - cat repo-list.txt +# - name: Print out all repos in file +# shell: bash +# run: | +# echo "Org name is:" +# cat org-name.txt +# echo "Full list of repos in org:" +# cat repo-list.txt - name: Fetch custom properties for each repo shell: bash @@ -98,17 +94,19 @@ runs: echo "Custom properties written to read-repo-properties.json" - - name: Print out the full read-repo-properties.json file - shell: bash - run: | - echo "Full read-repo-properties.json file is:" - cat read-repo-properties.json +# - name: Print out the full read-repo-properties.json file +# shell: bash +# run: | +# echo "" +# echo "Full read-repo-properties.json file is:" +# cat read-repo-properties.json +# echo "" - - name: Confirm the template file exists - shell: bash - run: | - echo "The template file for JSON output is:" - cat property-names.json +# - name: Confirm the template file exists +# shell: bash +# run: | +# echo "The template file for JSON output is:" +# cat property-names.json - name: Convert repo properties to YAML using template shell: bash @@ -146,8 +144,10 @@ runs: - name: Print out the read-repo-properties.yaml shell: bash run: | + echo "" echo "Full read-repo-properties.yaml file is:" cat read-repo-properties.yaml + echo "" - name: Overwrite existing file (if applicable) if: ${{ inputs.overwrite-existing-file == 'true' }} @@ -166,4 +166,3 @@ runs: git add repo-properties.yaml git commit -m "chore: commit repo custom properties to properties file" || echo "Nothing to commit" git push - From da4d586f658cf4d699314af9969b5d3715a70c45 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 15:12:44 -0500 Subject: [PATCH 39/48] remove commented out sections Signed-off-by: Andrew Brandt --- action.yaml | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/action.yaml b/action.yaml index d1f9e88..303a397 100644 --- a/action.yaml +++ b/action.yaml @@ -52,21 +52,13 @@ runs: - name: Extract property names into a JSON file shell: bash env: - GH_TOKEN: ${{ inputs.token }} # or use your PAT if needed + GH_TOKEN: ${{ inputs.token }} run: | ORG=$(cat org-name.txt) echo "Fetching property schema for org: $ORG" gh api --paginate "orgs/$ORG/properties/schema" | jq 'map(.property_name)' > property-names.json echo "Property names written to property-names.json" -# - name: Print out all repos in file -# shell: bash -# run: | -# echo "Org name is:" -# cat org-name.txt -# echo "Full list of repos in org:" -# cat repo-list.txt - - name: Fetch custom properties for each repo shell: bash env: @@ -94,20 +86,6 @@ runs: echo "Custom properties written to read-repo-properties.json" -# - name: Print out the full read-repo-properties.json file -# shell: bash -# run: | -# echo "" -# echo "Full read-repo-properties.json file is:" -# cat read-repo-properties.json -# echo "" - -# - name: Confirm the template file exists -# shell: bash -# run: | -# echo "The template file for JSON output is:" -# cat property-names.json - - name: Convert repo properties to YAML using template shell: bash run: | From 0d96689b9e2091dd3ea62dd8d6c5966c16c35304 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Mon, 21 Apr 2025 17:01:50 -0500 Subject: [PATCH 40/48] add GPG key signing to the action Signed-off-by: Andrew Brandt --- action.yaml | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index 303a397..1707eba 100644 --- a/action.yaml +++ b/action.yaml @@ -138,9 +138,37 @@ runs: - name: Commit values to repo-properties.yaml if: ${{ inputs.dry-run-enabled != 'true' }} shell: bash + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_KEY_CONTENTS }} + GPG_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }} run: | - git config user.name "${{ inputs.commit-author-name }}" - git config user.email "${{ inputs.commit-author-email }}" + # Import GPG key + echo "$GPG_PRIVATE_KEY" | gpg --batch --import + + # Get the GPG key ID + KEY_ID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/{print $5}' | head -n1) + + # Trust the key (avoid interactive trust prompts) + echo -e "5\ny\n" | gpg --command-fd 0 --expert --edit-key "$KEY_ID" trust + + # Configure Git to use this key + git config --global user.name "${{ inputs.commit-author-name }}" + git config --global user.email "${{ inputs.commit-author-email }}" + git config --global commit.gpgsign true + git config --global user.signingkey "$KEY_ID" + git config --global gpg.program gpg + + # Prevent pinentry prompt (for passphrase-protected keys) + echo "allow-loopback-pinentry" >> ~/.gnupg/gpg.conf + echo "use-agent" >> ~/.gnupg/gpg.conf + echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf + echo RELOADAGENT | gpg-connect-agent + export GPG_TTY=$(tty) + + # Make the commit git add repo-properties.yaml - git commit -m "chore: commit repo custom properties to properties file" || echo "Nothing to commit" + echo "$GPG_PASSPHRASE" | \ + gpg --batch --yes --passphrase-fd 0 \ + git commit -S -m "chore: commit repo custom properties to properties file" || echo "Nothing to commit" + git push From fefe1eda2df410887bd0f6dadae503eea8967469 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Tue, 22 Apr 2025 13:10:14 -0500 Subject: [PATCH 41/48] add gpg key contents and passphrase Signed-off-by: Andrew Brandt --- action.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 1707eba..c84b139 100644 --- a/action.yaml +++ b/action.yaml @@ -26,6 +26,13 @@ inputs: commit-author-email: description: 'Author of commit email address:' required: true + gpg-key-contents: + description: 'GPG Key Contents' + required: true + gpg-key-passphrase: + description: 'GPG Key Passphrase' + required: true + runs: using: "composite" @@ -139,8 +146,8 @@ runs: if: ${{ inputs.dry-run-enabled != 'true' }} shell: bash env: - GPG_PRIVATE_KEY: ${{ secrets.GPG_KEY_CONTENTS }} - GPG_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }} + GPG_PRIVATE_KEY: ${{ inputs.GPG_KEY_CONTENTS }} + GPG_PASSPHRASE: ${{ inputs.GPG_KEY_PASSPHRASE }} run: | # Import GPG key echo "$GPG_PRIVATE_KEY" | gpg --batch --import From c3c1e4b66eb421596a24d3c1a5e0671bb30dc593 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Tue, 22 Apr 2025 14:53:41 -0500 Subject: [PATCH 42/48] change caps Signed-off-by: Andrew Brandt --- action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index c84b139..9f7fb0c 100644 --- a/action.yaml +++ b/action.yaml @@ -146,8 +146,8 @@ runs: if: ${{ inputs.dry-run-enabled != 'true' }} shell: bash env: - GPG_PRIVATE_KEY: ${{ inputs.GPG_KEY_CONTENTS }} - GPG_PASSPHRASE: ${{ inputs.GPG_KEY_PASSPHRASE }} + GPG_PRIVATE_KEY: ${{ inputs.gpg-key-contents }} + GPG_PASSPHRASE: ${{ inputs.gpg-key-passphrase }} run: | # Import GPG key echo "$GPG_PRIVATE_KEY" | gpg --batch --import From 39f6064afee35b0f8d127f1a0e9258ca6d02c685 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Tue, 22 Apr 2025 14:56:34 -0500 Subject: [PATCH 43/48] rename inputs Signed-off-by: Andrew Brandt --- action.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yaml b/action.yaml index 9f7fb0c..116b8f5 100644 --- a/action.yaml +++ b/action.yaml @@ -26,10 +26,10 @@ inputs: commit-author-email: description: 'Author of commit email address:' required: true - gpg-key-contents: + commit-author-gpg-key-contents: description: 'GPG Key Contents' required: true - gpg-key-passphrase: + commit-author-gpg-key-passphrase: description: 'GPG Key Passphrase' required: true @@ -146,8 +146,8 @@ runs: if: ${{ inputs.dry-run-enabled != 'true' }} shell: bash env: - GPG_PRIVATE_KEY: ${{ inputs.gpg-key-contents }} - GPG_PASSPHRASE: ${{ inputs.gpg-key-passphrase }} + GPG_PRIVATE_KEY: ${{ inputs.commit-author-gpg-key-contents }} + GPG_PASSPHRASE: ${{ inputs.commit-author-gpg-key-passphrase }} run: | # Import GPG key echo "$GPG_PRIVATE_KEY" | gpg --batch --import From 49e7a3c74b61ec79eccd10a148a0e1c0c8bfe5d6 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Tue, 22 Apr 2025 14:59:36 -0500 Subject: [PATCH 44/48] fix the loopback issue Signed-off-by: Andrew Brandt --- action.yaml | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/action.yaml b/action.yaml index 116b8f5..ec2391b 100644 --- a/action.yaml +++ b/action.yaml @@ -151,31 +151,39 @@ runs: run: | # Import GPG key echo "$GPG_PRIVATE_KEY" | gpg --batch --import - - # Get the GPG key ID + + # Get key ID KEY_ID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/{print $5}' | head -n1) - - # Trust the key (avoid interactive trust prompts) - echo -e "5\ny\n" | gpg --command-fd 0 --expert --edit-key "$KEY_ID" trust - - # Configure Git to use this key + + # Trust the key + echo -e "5\ny\n" | gpg --batch --yes --command-fd 0 --edit-key "$KEY_ID" trust + + # Configure GPG for non-interactive use + mkdir -p ~/.gnupg + echo "use-agent" >> ~/.gnupg/gpg.conf + echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf + echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf + echo RELOADAGENT | gpg-connect-agent + export GPG_TTY=$(tty) + + # Configure Git git config --global user.name "${{ inputs.commit-author-name }}" git config --global user.email "${{ inputs.commit-author-email }}" git config --global commit.gpgsign true git config --global user.signingkey "$KEY_ID" git config --global gpg.program gpg - - # Prevent pinentry prompt (for passphrase-protected keys) - echo "allow-loopback-pinentry" >> ~/.gnupg/gpg.conf - echo "use-agent" >> ~/.gnupg/gpg.conf - echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf - echo RELOADAGENT | gpg-connect-agent + + # Set passphrase environment variable for Git GPG signing + export GIT_COMMITTER_NAME="${{ inputs.commit-author-name }}" + export GIT_COMMITTER_EMAIL="${{ inputs.commit-author-email }}" export GPG_TTY=$(tty) - - # Make the commit - git add repo-properties.yaml + + # Create the commit (sign with loopback) echo "$GPG_PASSPHRASE" | \ - gpg --batch --yes --passphrase-fd 0 \ - git commit -S -m "chore: commit repo custom properties to properties file" || echo "Nothing to commit" - + gpg --batch --yes --passphrase-fd 0 --pinentry-mode loopback \ + --local-user "$KEY_ID" \ + --output /dev/null --sign - 2>/dev/null + + git add repo-properties.yaml + git commit -S -m "chore: commit repo custom properties to properties file" || echo "Nothing to commit" git push From 69ff51795efc1e77b3922b7bebdf70ce1d72d159 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Tue, 22 Apr 2025 15:07:18 -0500 Subject: [PATCH 45/48] add signed off by line in commit message Signed-off-by: Andrew Brandt --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index ec2391b..c3dd361 100644 --- a/action.yaml +++ b/action.yaml @@ -185,5 +185,5 @@ runs: --output /dev/null --sign - 2>/dev/null git add repo-properties.yaml - git commit -S -m "chore: commit repo custom properties to properties file" || echo "Nothing to commit" + git commit -sSm "chore: commit repo custom properties to properties file" || echo "Nothing to commit" git push From 7521a6b3af4fae1509290c81144dd0ab5656f93d Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Tue, 22 Apr 2025 15:19:04 -0500 Subject: [PATCH 46/48] split the args apart Signed-off-by: Andrew Brandt --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index c3dd361..3854fa1 100644 --- a/action.yaml +++ b/action.yaml @@ -185,5 +185,5 @@ runs: --output /dev/null --sign - 2>/dev/null git add repo-properties.yaml - git commit -sSm "chore: commit repo custom properties to properties file" || echo "Nothing to commit" + git commit -sS -m "chore: commit repo custom properties to properties file" || echo "Nothing to commit" git push From 153658e210acdecd8ff4142e5ba082d8c736c2b6 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Tue, 22 Apr 2025 15:43:17 -0500 Subject: [PATCH 47/48] add expansions Signed-off-by: Andrew Brandt --- action.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yaml b/action.yaml index 3854fa1..492d2d4 100644 --- a/action.yaml +++ b/action.yaml @@ -150,7 +150,7 @@ runs: GPG_PASSPHRASE: ${{ inputs.commit-author-gpg-key-passphrase }} run: | # Import GPG key - echo "$GPG_PRIVATE_KEY" | gpg --batch --import + echo "${GPG_PRIVATE_KEY}" | gpg --batch --import # Get key ID KEY_ID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/{print $5}' | head -n1) @@ -170,7 +170,7 @@ runs: git config --global user.name "${{ inputs.commit-author-name }}" git config --global user.email "${{ inputs.commit-author-email }}" git config --global commit.gpgsign true - git config --global user.signingkey "$KEY_ID" + git config --global user.signingkey "${KEY_ID}" git config --global gpg.program gpg # Set passphrase environment variable for Git GPG signing @@ -179,9 +179,9 @@ runs: export GPG_TTY=$(tty) # Create the commit (sign with loopback) - echo "$GPG_PASSPHRASE" | \ + echo "${GPG_PASSPHRASE}" | \ gpg --batch --yes --passphrase-fd 0 --pinentry-mode loopback \ - --local-user "$KEY_ID" \ + --local-user "${KEY_ID}" \ --output /dev/null --sign - 2>/dev/null git add repo-properties.yaml From 1d8a1bb771cc1406b145ef6d2cb5d275a6f24589 Mon Sep 17 00:00:00 2001 From: Andrew Brandt Date: Tue, 22 Apr 2025 15:49:24 -0500 Subject: [PATCH 48/48] shorten name, remove extra line Signed-off-by: Andrew Brandt --- action.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 492d2d4..282390f 100644 --- a/action.yaml +++ b/action.yaml @@ -1,4 +1,4 @@ -name: 'Read Custom Properties of All Repos in an Organization' +name: 'Read Custom Properties' description: 'Read all the custom properties and values of all repos in an organization' author: 'Andrew Brandt ' organization: 'PandasWhoCode' @@ -33,7 +33,6 @@ inputs: description: 'GPG Key Passphrase' required: true - runs: using: "composite" steps: