Skip to content

Commit 70ccee2

Browse files
authored
Merge pull request #249 from Yubico/dennisdyallo/github-builds
ci: fix links for build output and add image hash
2 parents 83ae88a + b263995 commit 70ccee2

File tree

2 files changed

+43
-15
lines changed

2 files changed

+43
-15
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ jobs:
6969
contents: read
7070
packages: read
7171
attestations: write
72+
# Add an outputs section to the job to pass artifact IDs
73+
outputs:
74+
docs-log-id: ${{ steps.docs-log-upload.outputs.artifact-id }}
75+
docs-id: ${{ steps.docs-upload.outputs.artifact-id }}
76+
nuget-packages-id: ${{ steps.nuget-upload.outputs.artifact-id }}
77+
symbols-packages-id: ${{ steps.symbols-upload.outputs.artifact-id }}
78+
assemblies-id: ${{ steps.assemblies-upload.outputs.artifact-id }}
7279
steps:
7380
# Checkout the local repository
7481
- uses: actions/checkout@v4
@@ -99,6 +106,7 @@ jobs:
99106
100107
# Upload documentation log
101108
- name: "Save build artifacts: Docs log"
109+
id: docs-log-upload
102110
uses: actions/upload-artifact@v4
103111
with:
104112
name: Documentation log
@@ -107,6 +115,7 @@ jobs:
107115

108116
# Upload documentation
109117
- name: "Save build artifacts: Docs"
118+
id: docs-upload
110119
uses: actions/upload-artifact@v4
111120
with:
112121
name: Documentation
@@ -115,6 +124,7 @@ jobs:
115124

116125
# Upload NuGet packages
117126
- name: "Save build artifacts: Nuget Packages"
127+
id: nuget-upload
118128
uses: actions/upload-artifact@v4
119129
with:
120130
name: Nuget Packages
@@ -125,6 +135,7 @@ jobs:
125135

126136
# Upload symbols
127137
- name: "Save build artifacts: Symbols Packages"
138+
id: symbols-upload
128139
uses: actions/upload-artifact@v4
129140
with:
130141
name: Symbols Packages
@@ -135,6 +146,7 @@ jobs:
135146

136147
# Upload assemblies
137148
- name: "Save build artifacts: Assemblies"
149+
id: assemblies-upload
138150
uses: actions/upload-artifact@v4
139151
with:
140152
name: Assemblies
@@ -187,18 +199,28 @@ jobs:
187199
build-summary:
188200
name: Build summary
189201
runs-on: ubuntu-latest
190-
needs: [build-artifacts, publish-internal, upload-docs] # Add upload-docs to needs
191-
if: always() # Run this job even if other jobs fail
202+
needs: [build-artifacts, publish-internal, upload-docs]
203+
if: always()
192204
steps:
193205
- name: Generate build summary
194206
env:
195-
# Pass job results and outputs into the step's environment
207+
# Pass job results into the environment
196208
RUN_TESTS_RESULT: ${{ needs.run-tests.result }}
197209
BUILD_ARTIFACTS_RESULT: ${{ needs.build-artifacts.result }}
198210
UPLOAD_DOCS_RESULT: ${{ needs.upload-docs.result }}
199211
PUBLISH_INTERNAL_RESULT: ${{ needs.publish-internal.result }}
200212
DOCS_IMAGE_TAG: ${{ needs.upload-docs.outputs.image-tag }}
213+
DOCS_IMAGE_HASH: ${{ needs.upload-docs.outputs.image-hash}}
214+
215+
# Pass artifact IDs from the build-artifacts job outputs
216+
DOCS_LOG_ID: ${{ needs.build-artifacts.outputs.docs-log-id }}
217+
DOCS_ID: ${{ needs.build-artifacts.outputs.docs-id }}
218+
NUGET_ID: ${{ needs.build-artifacts.outputs.nuget-packages-id }}
219+
SYMBOLS_ID: ${{ needs.build-artifacts.outputs.symbols-packages-id }}
220+
ASSEMBLIES_ID: ${{ needs.build-artifacts.outputs.assemblies-id }}
201221
run: |
222+
ARTIFACT_URL_BASE="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts"
223+
202224
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
203225
echo "" >> $GITHUB_STEP_SUMMARY
204226
echo "### Job Status" >> $GITHUB_STEP_SUMMARY
@@ -210,21 +232,25 @@ jobs:
210232
echo "| Publish to internal NuGet | **${{ env.PUBLISH_INTERNAL_RESULT }}** |" >> $GITHUB_STEP_SUMMARY
211233
echo "" >> $GITHUB_STEP_SUMMARY
212234
213-
echo "### Built Artifacts" >> $GITHUB_STEP_SUMMARY
214-
echo "Links to artifacts produced by this build run:" >> $GITHUB_STEP_SUMMARY
215-
echo "" >> $GITHUB_STEP_SUMMARY
216-
echo "- [Documentation log](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/Documentation_log)" >> $GITHUB_STEP_SUMMARY
217-
echo "- [Documentation Site](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/Documentation)" >> $GITHUB_STEP_SUMMARY
218-
echo "- [Nuget Packages](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/Nuget_Packages)" >> $GITHUB_STEP_SUMMARY
219-
echo "- [Symbols Packages](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/Symbols_Packages)" >> $GITHUB_STEP_SUMMARY
220-
echo "- [Assemblies](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/Assemblies)" >> $GITHUB_STEP_SUMMARY
221-
echo "" >> $GITHUB_STEP_SUMMARY
235+
# Only show artifacts list if the build succeeded
236+
if [ "${{ env.BUILD_ARTIFACTS_RESULT }}" == "success" ]; then
237+
echo "### Built Artifacts" >> $GITHUB_STEP_SUMMARY
238+
echo "Direct links to artifacts produced by this build run:" >> $GITHUB_STEP_SUMMARY
239+
echo "" >> $GITHUB_STEP_SUMMARY
240+
echo "- [Documentation log]($ARTIFACT_URL_BASE/${{ env.DOCS_LOG_ID }})" >> $GITHUB_STEP_SUMMARY
241+
echo "- [Documentation Site]($ARTIFACT_URL_BASE/${{ env.DOCS_ID }})" >> $GITHUB_STEP_SUMMARY
242+
echo "- [Nuget Packages]($ARTIFACT_URL_BASE/${{ env.NUGET_ID }})" >> $GITHUB_STEP_SUMMARY
243+
echo "- [Symbols Packages]($ARTIFACT_URL_BASE/${{ env.SYMBOLS_ID }})" >> $GITHUB_STEP_SUMMARY
244+
echo "- [Assemblies]($ARTIFACT_URL_BASE/${{ env.ASSEMBLIES_ID }})" >> $GITHUB_STEP_SUMMARY
245+
echo "" >> $GITHUB_STEP_SUMMARY
246+
fi
222247
223-
# Conditionally add the Docker image tag to the summary if the upload-docs job was successful
248+
# Conditionally add the Docker image tag to the summary
224249
if [ "${{ env.UPLOAD_DOCS_RESULT }}" == "success" ]; then
225250
echo "### Documentation Docker Image" >> $GITHUB_STEP_SUMMARY
226251
echo "A new documentation Docker image was pushed with the tag:" >> $GITHUB_STEP_SUMMARY
227252
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
228253
echo "${{ env.DOCS_IMAGE_TAG }}" >> $GITHUB_STEP_SUMMARY
254+
echo "${{ env.DOCS_IMAGE_HASH }}" >> $GITHUB_STEP_SUMMARY
229255
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
230256
fi

.github/workflows/upload-docs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ jobs:
3737
runs-on: ubuntu-latest
3838
# Define an output for this job
3939
outputs:
40-
image-tag: ${{ steps.push_image.outputs.tag }}
40+
image-tag: ${{ steps.push_image.outputs.imagetag }}
41+
image-hash: ${{ steps.push_image.outputs.imagehash }}
4142
steps:
4243
# Checkout the local repository as we need the Dockerfile and other things even for this step.
4344
- uses: actions/checkout@v4
@@ -69,4 +70,5 @@ jobs:
6970
docker tag "${IMAGE_NAME}:${{ github.sha }}" "${FULL_IMAGE_TAG}"
7071
docker push "${FULL_IMAGE_TAG}"
7172
# Use GITHUB_OUTPUT to make the full tag available to the job and workflow
72-
echo "tag=${FULL_IMAGE_TAG}" >> $GITHUB_OUTPUT
73+
echo "imagetag=${FULL_IMAGE_TAG}" >> $GITHUB_OUTPUT
74+
echo "imagehash=${{ github.sha }}" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)