re: Add data links to build summary for screenshots #153
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Build VBA | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- dev* | |
permissions: | |
id-token: write | |
attestations: write | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: "Build VBA-Enabled Documents (using own action)" | |
id: build_vba | |
uses: ./ | |
with: | |
source-dir: "./tests" | |
test-framework: "rubberduck" | |
timeout-minutes: 20 | |
- name: "Upload Build Artifact" | |
uses: actions/upload-artifact@v4 | |
id: "upload" | |
with: | |
name: "VBA-Enabled-Documents" | |
path: "./tests/out/*" | |
if-no-files-found: warn | |
- name: "Take exiting screenshot" | |
if: always() | |
run: | | |
. "./scripts/utils/Screenshot.ps1" | |
# Create the directory if it does not exist | |
if (!(Test-Path -Path ${{ github.workspace }}/tests/screenshots)) { | |
New-Item -ItemType Directory -Path ${{ github.workspace }}/tests/screenshots | |
} | |
# Minimize PowerShell window | |
. "./scripts/utils/Minimize.ps1" | |
Minimize-Window "Administrator: C:\Program Files\PowerShell\7\pwsh.EXE" | |
Take-Screenshot -OutputPath ${{ github.workspace }}/tests/screenshots/ExitScreenshot.png | |
shell: pwsh | |
# TODO: Check if better method to visualize the screenshots: https://github.com/actions/upload-artifact/issues/14 | |
- name: "Upload Screenshots" | |
# Run this step even if the build failed | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "Screenshots" | |
path: "./tests/screenshots/*" | |
if-no-files-found: warn | |
- name: "Create itty.bitty links for Screenshots" | |
if: always() | |
id: create_itty_links | |
run: | | |
# Import the Create-IttyBittyLink function | |
. "./scripts/utils/Create-IttyBittyLink.ps1" | |
$screenshotDir = "${{ github.workspace }}/tests/screenshots" | |
$outputPath = "$screenshotDir/itty_bitty_link.txt" | |
# Create itty.bitty link | |
$ittyBittyLink = Create-IttyBittyLink -ScreenshotDirectory $screenshotDir -OutputPath $outputPath -Verbose | |
# Output the link for the GitHub Actions log | |
Write-Output "Screenshots viewable at: $ittyBittyLink" | |
# Set the output for potential use by other steps | |
echo "ITTY_BITTY_LINK=$ittyBittyLink" | Out-File -FilePath $env:GITHUB_OUTPUT -Append | |
# Write to GitHub Actions build summary, line by line to avoid YAML issues | |
if ($env:GITHUB_STEP_SUMMARY) { | |
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "## VBA Build Screenshots" | |
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "" | |
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "View all screenshots from this build: [Open Screenshots Viewer]($ittyBittyLink)" | |
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "" | |
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "**Last Updated:** $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | |
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "" | |
} | |
shell: pwsh | |
continue-on-error: true | |
- name: "Attestation" | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-name: "VBA-Enabled-Documents" | |
subject-digest: sha256:${{ steps.upload.outputs.artifact-digest }} |