Skip to content

Commit 83ae88a

Browse files
authored
Merge pull request #248 from Yubico/dennisdyallo/github-builds
ci: Add comprehensive summary for build
2 parents 90a8a2a + cae555f commit 83ae88a

File tree

2 files changed

+62
-6
lines changed

2 files changed

+62
-6
lines changed

.github/workflows/build.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ on:
4747
type: string
4848
schedule:
4949
- cron: '0 0 * * *' # Every day at midnight
50-
50+
5151
jobs:
5252
run-tests:
5353
name: Run tests
@@ -183,3 +183,48 @@ jobs:
183183
dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Yubico/index.json"
184184
dotnet nuget push $core --source "github" --api-key ${{ secrets.GITHUB_TOKEN }}
185185
dotnet nuget push $yubikey --source "github" --api-key ${{ secrets.GITHUB_TOKEN }}
186+
187+
build-summary:
188+
name: Build summary
189+
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
192+
steps:
193+
- name: Generate build summary
194+
env:
195+
# Pass job results and outputs into the step's environment
196+
RUN_TESTS_RESULT: ${{ needs.run-tests.result }}
197+
BUILD_ARTIFACTS_RESULT: ${{ needs.build-artifacts.result }}
198+
UPLOAD_DOCS_RESULT: ${{ needs.upload-docs.result }}
199+
PUBLISH_INTERNAL_RESULT: ${{ needs.publish-internal.result }}
200+
DOCS_IMAGE_TAG: ${{ needs.upload-docs.outputs.image-tag }}
201+
run: |
202+
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
203+
echo "" >> $GITHUB_STEP_SUMMARY
204+
echo "### Job Status" >> $GITHUB_STEP_SUMMARY
205+
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
206+
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
207+
echo "| Run tests | **${{ env.RUN_TESTS_RESULT }}** |" >> $GITHUB_STEP_SUMMARY
208+
echo "| Build artifacts | **${{ env.BUILD_ARTIFACTS_RESULT }}** |" >> $GITHUB_STEP_SUMMARY
209+
echo "| Upload docs | **${{ env.UPLOAD_DOCS_RESULT }}** |" >> $GITHUB_STEP_SUMMARY
210+
echo "| Publish to internal NuGet | **${{ env.PUBLISH_INTERNAL_RESULT }}** |" >> $GITHUB_STEP_SUMMARY
211+
echo "" >> $GITHUB_STEP_SUMMARY
212+
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
222+
223+
# Conditionally add the Docker image tag to the summary if the upload-docs job was successful
224+
if [ "${{ env.UPLOAD_DOCS_RESULT }}" == "success" ]; then
225+
echo "### Documentation Docker Image" >> $GITHUB_STEP_SUMMARY
226+
echo "A new documentation Docker image was pushed with the tag:" >> $GITHUB_STEP_SUMMARY
227+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
228+
echo "${{ env.DOCS_IMAGE_TAG }}" >> $GITHUB_STEP_SUMMARY
229+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
230+
fi

.github/workflows/upload-docs.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@
1414

1515
name: Upload documentation to GCP
1616

17-
on:
17+
on:
1818
workflow_call:
19+
# Define an output for this reusable workflow
20+
outputs:
21+
image-tag:
22+
description: "The full tag of the pushed documentation Docker image"
23+
value: ${{ jobs.upload_docs.outputs.image-tag }}
1924

2025
permissions:
2126
id-token: write
@@ -30,6 +35,9 @@ env:
3035
jobs:
3136
upload_docs:
3237
runs-on: ubuntu-latest
38+
# Define an output for this job
39+
outputs:
40+
image-tag: ${{ steps.push_image.outputs.tag }}
3341
steps:
3442
# Checkout the local repository as we need the Dockerfile and other things even for this step.
3543
- uses: actions/checkout@v4
@@ -44,7 +52,7 @@ jobs:
4452
- name: Docker build
4553
run: |
4654
docker build -t "${IMAGE_NAME}:${{ github.sha }}" .
47-
55+
4856
# Authenticate to Google Cloud
4957
- name: Authenticate
5058
uses: google-github-actions/auth@v2
@@ -54,8 +62,11 @@ jobs:
5462

5563
# Push our docker image to GCP
5664
- name: Push Docker image
65+
id: push_image # Add an ID to reference this step's outputs
5766
run: |
5867
gcloud auth configure-docker ${IMAGE_REGISTRY_URL} --project ${IMAGE_REGISTRY_PROJECT}
59-
docker tag "${IMAGE_NAME}:${{ github.sha }}" "${IMAGE_REGISTRY_URL}/${IMAGE_REGISTRY_PROJECT}/${IMAGE_REPOSITORY}/${IMAGE_NAME}:${{ github.sha }}"
60-
docker push "${IMAGE_REGISTRY_URL}/${IMAGE_REGISTRY_PROJECT}/${IMAGE_REPOSITORY}/${IMAGE_NAME}:${{ github.sha }}"
61-
echo "New image tag: ${{ github.sha }}"
68+
FULL_IMAGE_TAG="${IMAGE_REGISTRY_URL}/${IMAGE_REGISTRY_PROJECT}/${IMAGE_REPOSITORY}/${IMAGE_NAME}:${{ github.sha }}"
69+
docker tag "${IMAGE_NAME}:${{ github.sha }}" "${FULL_IMAGE_TAG}"
70+
docker push "${FULL_IMAGE_TAG}"
71+
# Use GITHUB_OUTPUT to make the full tag available to the job and workflow
72+
echo "tag=${FULL_IMAGE_TAG}" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)