Skip to content

Commit 2d99640

Browse files
committed
Add Badge Updater For Private
Signed-off-by: Stephen Williams <stephenw@mindpointgroup.com>
1 parent 2e63ba6 commit 2d99640

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

.github/workflows/export-badges-private.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
else
4444
color=lightgrey; msg=Unknown
4545
fi
46-
echo '{ "schemaVersion": 1, "label": "Remediate Pipeline", "message": "'"$msg"'", "color": "color": "brightgreen" }' > $OUT_DIR/remediate.json
46+
echo '{ "schemaVersion": 1, "label": "Remediate Pipeline", "message": "'"$msg"'", "color": "brightgreen" }' > $OUT_DIR/remediate.json
4747
4848
# GPO pipeline badge
4949
status=$(gh run list -R "${{ inputs.repo_name }}" --workflow="main_pipeline_validation_gpo.yml" --json status,conclusion --jq '.[0] | .status + ":" + .conclusion' || echo "unknown:unknown")
@@ -54,7 +54,7 @@ jobs:
5454
else
5555
color=lightgrey; msg=Unknown
5656
fi
57-
echo '{ "schemaVersion": 1, "label": "GPO Pipeline", "message": "'"$msg"'", "color": "color": "brightgreen" }' > $OUT_DIR/gpo.json
57+
echo '{ "schemaVersion": 1, "label": "GPO Pipeline", "message": "'"$msg"'", "color": "brightgreen" }' > $OUT_DIR/gpo.json
5858
5959
# Pull requests
6060
prs=$(gh pr list -R "${{ inputs.repo_name }}" --json number --jq 'length')
@@ -100,40 +100,42 @@ jobs:
100100
echo "Cloning self_hosted branch of github_windows_IaC..."
101101
git clone --branch self_hosted https://x-access-token:${{ secrets.BADGE_PUSH_TOKEN }}@github.com/ansible-lockdown/github_windows_IaC.git target
102102
103-
echo "Preparing badge directory: badges/${{ inputs.repo_name }}"
104-
mkdir -p target/badges/${{ inputs.repo_name }}
103+
repo_short=$(basename "${{ inputs.repo_name }}")
104+
105+
echo "Preparing badge directory: target/badges/$repo_short"
106+
mkdir -p target/badges/$repo_short
105107
106108
echo "Syncing badge files with rsync (only updated ones will be copied)..."
107-
if [ -d "output/badges/${{ inputs.repo_name }}" ]; then
108-
repo_short=$(basename "${{ inputs.repo_name }}")
109+
if [ -d "output/badges/$repo_short" ]; then
109110
rsync -a --delete --checksum output/badges/$repo_short/ target/badges/$repo_short/ | tee sync_log.txt
110111
else
111-
echo "Warning: No badge output found in output/badges/${{ inputs.repo_name }}"
112+
echo "Warning: No badge output found in output/badges/$repo_short"
112113
fi
113114
114115
echo "Files that were updated/copied/removed:"
115116
cat sync_log.txt || echo "No rsync output available"
116117
117-
echo "Final contents of target/badges/${{ inputs.repo_name }}:"
118-
ls -al target/badges/${{ inputs.repo_name }} || echo "Folder does not exist or is empty"
118+
echo "Final contents of target/badges/$repo_short:"
119+
ls -al target/badges/$repo_short || echo "Folder does not exist or is empty"
119120
120121
- name: Commit and push to self_hosted branch
121122
run: |
123+
repo_short=$(basename "${{ inputs.repo_name }}")
122124
cd target
123125
124126
echo "Running git status before commit:"
125127
git status
126128
127129
echo "Adding changes to staging:"
128-
git add badges/${{ inputs.repo_name }}
130+
git add badges/$repo_short
129131
130-
echo "Showing staged changes (git diff --cached):"
131-
git diff --cached || echo "No staged changes diff"
132+
echo "Showing staged changes:"
133+
git diff --cached || true
132134
133135
if git diff --cached --quiet; then
134136
echo "No changes detected – skipping commit."
135137
else
136138
echo "Changes detected – committing and pushing..."
137-
git commit -m "Update PRIVATE badges for ${{ inputs.repo_name }}"
139+
git commit -m "Update PRIVATE badges for $repo_short"
138140
git push origin self_hosted
139141
fi

0 commit comments

Comments
 (0)