Skip to content

Commit ed39fc3

Browse files
authored
Fix badge publication in CI (#549)
There is a typo that causes deletion of old badges to fail. This was not captured in the presubmit because the badge publication job did not run. I've changed it to run regardless whether the workflow is presubmit or nightly, but let the publishing destination be a mock one if the workflow is run as presubmit.
1 parent 4aeff54 commit ed39fc3

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Diff for: .github/workflows/_finalize.yaml

+7-10
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ jobs:
172172

173173
publish-badge:
174174
needs: [upload-badge]
175-
if: inputs.PUBLISH_BADGE == true
176175
runs-on: ubuntu-22.04
177176
env:
178177
# Name/bash regex for shields.io endpoint JSON files
@@ -184,14 +183,9 @@ jobs:
184183
github-token: ${{ secrets.NVJAX_GIST_TOKEN }}
185184
script: |
186185
const srcId = "${{ needs.upload-badge.outputs.GIST_ID }}";
187-
const dstId = "${{ vars.BADGE_ENDPOINT_GIST_ID }}";
186+
const dstId = "${{ inputs.PUBLISH_BADGE && vars.BADGE_ENDPOINT_GIST_ID || vars.MOCK_BADGE_ENDPOINT_GIST_ID }}";
188187
const { PUBLISH_BADGE_FILES } = process.env;
189188
190-
// Fetch files from source gist
191-
const { data: srcData } = await github.rest.gists.get({
192-
gist_id: srcId
193-
});
194-
195189
// Fetch existing files from destination gist
196190
const { data: dstData } = await github.rest.gists.get({
197191
gist_id: dstId
@@ -200,11 +194,14 @@ jobs:
200194
// Mark existing files in destination gist for deletion
201195
let filesToUpdate = {};
202196
for (const filename of Object.keys(dstData.files)) {
203-
filesToUpdate[filename] = {
204-
content: null
205-
};
197+
filesToUpdate[filename] = null;
206198
}
207199
200+
// Fetch files from source gist
201+
const { data: srcData } = await github.rest.gists.get({
202+
gist_id: srcId
203+
});
204+
208205
// Add or update files based on the pattern
209206
const pattern = new RegExp(`${PUBLISH_BADGE_FILES}`);
210207
for (const [filename, fileObj] of Object.entries(srcData.files)) {

0 commit comments

Comments
 (0)