|
10 | 10 | REPO_NAME: "documentation"
|
11 | 11 | FRONT_DOOR_USERNAME: ${{ secrets.FRONT_DOOR_USERNAME }}
|
12 | 12 | FRONT_DOOR_PASSWORD: ${{ secrets.FRONT_DOOR_PASSWORD }}
|
13 |
| - GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} |
| 13 | + GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} |
| 14 | + MAIN_REPORT_ARTIFACT_NAME: "lighthouse-reports-main" |
14 | 15 |
|
15 | 16 | jobs:
|
16 | 17 | deploy-example-site:
|
@@ -46,10 +47,32 @@ jobs:
|
46 | 47 | REPORT_NAME: "pr"
|
47 | 48 | run: |
|
48 | 49 | node performance/lighthouse-script.js
|
| 50 | + - name: Retrieve the latest artifact ID for lighthouse report main |
| 51 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
| 52 | + id: fetch-artifact-id |
| 53 | + with: |
| 54 | + script: | |
| 55 | + const { owner, repo } = context.issue; |
| 56 | + const response = github.rest.actions.listArtifactsForRepo({ |
| 57 | + owner, |
| 58 | + repo, |
| 59 | + }); |
| 60 | +
|
| 61 | + const artifactName = process.env.MAIN_REPORT_ARTIFACT_NAME; |
| 62 | + const filteredArtifacts = artifacts.data.artifacts.filter(a => a.name === artifactName); |
| 63 | + if(filteredArtifacts.length === 0) { |
| 64 | + core.setFailed(`Error: Not able to find artifact with name ${artifactName}`); |
| 65 | + } |
| 66 | + else { |
| 67 | + const latestArtifact = filteredArtifacts.sort((a, b) => new Date(b.created_at) - new Date(a.created_at))[0]; |
| 68 | + console.log(`Success! Found the latest artifact with name #{artifactName}`); |
| 69 | + core.setOutput("artifact_id", latestArtifact.id); |
| 70 | + } |
| 71 | + result-encoding: string |
49 | 72 | - name: Download the artifact for main
|
50 | 73 | uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
|
51 | 74 | with:
|
52 |
| - name: lighthouse-reports-main |
| 75 | + artifact-ids: ${{ steps.fetch_artifact.outputs.artifact_id }} |
53 | 76 | path: ./main-report
|
54 | 77 | - name: Move the main report artifact to same directory as pr report
|
55 | 78 | run: |
|
|
0 commit comments