Skip to content

Commit ce409f6

Browse files
committed
Improve debug PR image comment template
1 parent 4a023ae commit ce409f6

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

.github/workflows/pr-debug-publish.yaml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ jobs:
4040
echo "head_sha=${head_sha}" >> $GITHUB_OUTPUT
4141
echo "head_sha_short=${head_sha:0:7}" >> $GITHUB_OUTPUT
4242
echo "PR ${pr_number}" >> $GITHUB_STEP_SUMMARY
43-
echo "PR SHA: ${head_sha}" >> $GITHUB_STEP_SUMMARY
44-
echo "PR SHA Short: ${head_sha:0:7}" >> $GITHUB_STEP_SUMMARY
43+
echo "PR SHA: ${head_sha:0:7}" >> $GITHUB_STEP_SUMMARY
44+
echo "PR SHA FULL: ${head_sha}" >> $GITHUB_STEP_SUMMARY
4545
build_dev_helm_locker:
4646
name: Build and push helm-locker
4747
runs-on: ${{ github.repository == 'rancher/prometheus-federator' && format('runs-on,image=ubuntu22-full-x64,runner=4cpu-linux-x64,run-id={0}', github.run_id) || 'ubuntu-latest' }}
@@ -177,6 +177,7 @@ jobs:
177177
name: Comment on PR with image details
178178
runs-on: ${{ github.repository == 'rancher/prometheus-federator' && format('runs-on,image=ubuntu22-full-x64,runner=4cpu-linux-x64,run-id={0}', github.run_id) || 'ubuntu-latest' }}
179179
needs:
180+
- prepare_pr_info
180181
- build_dev_helm_locker
181182
- build_dev_helm_project_operator
182183
- build_dev_prometheus_federator
@@ -189,6 +190,8 @@ jobs:
189190
meta-helm-locker: ${{ needs.build_dev_helm_locker.outputs.tags }}
190191
meta-helm-project-operator: ${{ needs.build_dev_helm_project_operator.outputs.tags }}
191192
meta-prometheus-federator: ${{ needs.build_dev_prometheus_federator.outputs.tags }}
193+
prNumber: ${{ github.event.inputs.pr_number }}
194+
shortSha: ${{ needs.prepare_pr_info.outputs.head_sha_short }}
192195
with:
193196
script: |
194197
const prNumber = context.payload.inputs.pr_number;
@@ -210,14 +213,31 @@ jobs:
210213
}
211214
];
212215
213-
const prepareTags = (tags) => tags.split(' ').join('\`,\n \`')
216+
const prepareContainerImageText = function(imageInfo) {
217+
const rawTags = process.env[imageInfo.key];
218+
const tags = rawTags.split(' ')
219+
.map(tag => `\t- \`${tag}\``)
220+
.join('\n');
221+
222+
return `- [**${imageInfo.name}**](${imageInfo.url}) - Tags:\n${tags}`;
223+
}
214224
const commentBody = images
215-
.map(image => `- **${image.name}**: [Link to image](${image.url}):\n Tags: \`${prepareTags(process.env[image.key])}\``)
216-
.join('\n\n');
217-
225+
.map(prepareContainerImageText)
226+
.join('\n');
227+
228+
const helmDebugValues = `#### Helm Debug Values:
229+
\`\`\`yaml
230+
image:
231+
pullPolicy: Always
232+
registry: ghcr.io
233+
repository: rancher/prometheus-federator
234+
tag: pr-${process.env.prNumber}-${process.env.shortSha}
235+
\`\`\`\n`;
236+
const fullCommentBody = `${commentBody}\n\n${helmDebugValues}`;
237+
218238
github.rest.issues.createComment({
219239
issue_number: prNumber,
220240
owner: context.repo.owner,
221241
repo: context.repo.repo,
222-
body: `### Images built for PR #${prNumber}:\n\n${commentBody}`
242+
body: `### Images built for PR #${prNumber}:\n\n${fullCommentBody}`
223243
});

0 commit comments

Comments
 (0)