Skip to content

Commit a1043be

Browse files
authored
Upgrade actions and packages related to artifacts (#3540)
1 parent 0471c3c commit a1043be

File tree

5 files changed

+63
-19
lines changed

5 files changed

+63
-19
lines changed

.github/actions/load-img/action.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: openverse/load-img
22
description: Download and import Docker images from artifacts
33

44
inputs:
5+
run_id:
6+
description: The ID of the current workflow run
7+
required: true
8+
59
setup_images:
610
default: "upstream_db ingestion_server catalog api api_nginx frontend"
711
description: Space-separated list of image names
@@ -23,18 +27,29 @@ runs:
2327
- name: Install `@actions/artifact`
2428
shell: bash
2529
run: |
26-
pnpm install @actions/artifact@1 -w
30+
pnpm install @actions/artifact -w
2731
2832
- name: Download images
2933
uses: actions/github-script@v6
3034
with:
3135
script: |
32-
const artifact = require("@actions/artifact")
33-
const artifactClient = artifact.create()
34-
const images = "${{ inputs.setup_images }}".split(" ")
35-
for (image of images) {
36-
await artifactClient.downloadArtifact(image, "/tmp", { createArtifactFolder: false })
36+
const { DefaultArtifactClient } = require('@actions/artifact')
37+
const artifact = new DefaultArtifactClient()
38+
const images = '${{ inputs.setup_images }}'.split(' ')
39+
const [repositoryOwner, repositoryName] = '${{ github.repository }}'.split('/')
40+
const findBy = {
41+
repositoryOwner,
42+
repositoryName,
43+
workflowRunId: '${{ inputs.run_id }}',
44+
token: '${{ github.token }}',
3745
}
46+
const workflowArtifacts = await artifact.listArtifacts({ findBy })
47+
await Promise.all(
48+
workflowArtifacts.artifacts
49+
.filter((item) => images.includes(item.name))
50+
.map((item) => artifact.downloadArtifact(item.id, { findBy, path: '/tmp' }))
51+
)
52+
console.log('Downloaded artifacts')
3853
3954
- name: Load images
4055
shell: bash

.github/workflows/ci_cd.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,16 @@ jobs:
231231
FRONTEND_PNPM_VERSION=${{ steps.prepare-build-args.outputs.frontend_pnpm_version }}
232232
233233
- name: Upload image `${{ matrix.image }}`
234-
uses: actions/upload-artifact@v3
234+
id: upload-img
235+
uses: actions/upload-artifact@v4
235236
with:
236237
name: ${{ matrix.image }}
237238
path: /tmp/${{ matrix.image }}.tar
238239

240+
- name: Show artifact ID
241+
run: |
242+
echo '${{ matrix.image }} artifact ID is ${{ steps.upload-img.outputs.artifact-id }}'
243+
239244
###########
240245
# Catalog #
241246
###########
@@ -267,6 +272,7 @@ jobs:
267272
- name: Load Docker images
268273
uses: ./.github/actions/load-img
269274
with:
275+
run_id: ${{ github.run_id }}
270276
setup_images: upstream_db catalog
271277

272278
- name: Run tests
@@ -298,6 +304,7 @@ jobs:
298304
- name: Load Docker images
299305
uses: ./.github/actions/load-img
300306
with:
307+
run_id: ${{ github.run_id }}
301308
setup_images: upstream_db catalog
302309

303310
- name: Check DAG documentation
@@ -334,6 +341,7 @@ jobs:
334341
- name: Load Docker images
335342
uses: ./.github/actions/load-img
336343
with:
344+
run_id: ${{ github.run_id }}
337345
setup_images: upstream_db ingestion_server
338346

339347
- name: Run ingestion-server tests
@@ -346,7 +354,7 @@ jobs:
346354
347355
- name: Upload ingestion test logs
348356
if: success() || failure()
349-
uses: actions/upload-artifact@v3
357+
uses: actions/upload-artifact@v4
350358
with:
351359
name: ing_logs
352360
path: ingestion_server/test/ingestion_logs.txt
@@ -383,6 +391,7 @@ jobs:
383391
- name: Load Docker images
384392
uses: ./.github/actions/load-img
385393
with:
394+
run_id: ${{ github.run_id }}
386395
setup_images: upstream_db ingestion_server api
387396

388397
- name: Start API, ingest and index test data
@@ -399,7 +408,7 @@ jobs:
399408
400409
- name: Upload API test logs
401410
if: success() || failure()
402-
uses: actions/upload-artifact@v3
411+
uses: actions/upload-artifact@v4
403412
with:
404413
name: api_logs
405414
path: api_logs
@@ -447,6 +456,7 @@ jobs:
447456
- name: Load Docker images
448457
uses: ./.github/actions/load-img
449458
with:
459+
run_id: ${{ github.run_id }}
450460
setup_images: upstream_db ingestion_server api
451461

452462
- name: Run check recipe
@@ -456,7 +466,7 @@ jobs:
456466

457467
- name: Upload schema
458468
if: matrix.name == 'test_doc'
459-
uses: actions/upload-artifact@v3
469+
uses: actions/upload-artifact@v4
460470
with:
461471
name: openapi.json
462472
path: ./api/openapi.json
@@ -653,7 +663,7 @@ jobs:
653663
- name: Run Playwright tests
654664
run: just frontend/run ${{ matrix.script }} --workers=2
655665

656-
- uses: actions/upload-artifact@v3
666+
- uses: actions/upload-artifact@v4
657667
if: failure()
658668
id: test-results
659669
with:
@@ -771,7 +781,7 @@ jobs:
771781
# Docs will be located at `/tmp/docs`.
772782

773783
- name: Upload documentation
774-
uses: actions/upload-artifact@v3
784+
uses: actions/upload-artifact@v4
775785
with:
776786
name: documentation
777787
path: /tmp/docs/
@@ -809,7 +819,7 @@ jobs:
809819

810820
steps:
811821
- name: Download documentation
812-
uses: actions/download-artifact@v3
822+
uses: actions/download-artifact@v4
813823
with:
814824
name: documentation
815825
path: /tmp/docs
@@ -926,6 +936,7 @@ jobs:
926936
- name: Load Docker image `${{ matrix.image }}`
927937
uses: ./.github/actions/load-img
928938
with:
939+
run_id: ${{ github.run_id }}
929940
setup_images: ${{ matrix.image }}
930941

931942
- name: Load and tag image `${{ matrix.image }}` (latest & sha)

.github/workflows/pr_automations_init.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
PR_NODE_ID: ${{ github.event.pull_request.node_id }}
4545

4646
- name: Upload event info as artifact
47-
uses: actions/upload-artifact@v3
47+
uses: actions/upload-artifact@v4
4848
with:
4949
name: event_info
5050
path: /tmp/event.json

.github/workflows/push_docker_image.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,32 @@ jobs:
2626
username: ${{ github.actor }}
2727
password: ${{ secrets.GITHUB_TOKEN }}
2828

29+
- name: Determine successful run ID
30+
id: determine-run-id
31+
uses: actions/github-script@v7
32+
with:
33+
github-token: ${{ secrets.ACCESS_TOKEN }}
34+
script: |
35+
const [owner, repo] = '${{ github.repository }}'.split('/')
36+
const { data: runs } = await github.rest.actions.listWorkflowRunsForRepo({
37+
owner,
38+
repo,
39+
branch: 'main',
40+
event: 'push',
41+
status: 'success',
42+
head_sha: '${{ github.event.inputs.commit }}',
43+
})
44+
const runId = runs.workflow_runs.find((run) => run.name === 'CI + CD').id
45+
core.setOutput('run_id', runId)
46+
2947
- name: Download image `${{ github.event.inputs.image }}`
30-
uses: dawidd6/action-download-artifact@v2
48+
uses: actions/download-artifact@v4
3149
with:
32-
workflow: ci_cd.yml
33-
workflow_conclusion: success
34-
commit: ${{ github.event.inputs.commit }}
3550
name: ${{ github.event.inputs.image }}
3651
path: /tmp
52+
github_token: ${{ secrets.ACCESS_TOKEN }}
53+
repository: ${{ github.repository }}
54+
run_id: ${{ steps.determine-run-id.outputs.run_id }}
3755

3856
- name: Load and tag image `${{ github.event.inputs.image }}`
3957
env:

.github/workflows/renovate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
# To solve *that*, we'd have to extract to root (/), which isn't safe.
7979
tar -czvf "$cache_archive" -C "$cache_dir" .
8080
81-
- uses: actions/upload-artifact@v3
81+
- uses: actions/upload-artifact@v4
8282
if: github.event.inputs.repoCache != 'disabled'
8383
with:
8484
name: ${{ env.cache_key }}

0 commit comments

Comments
 (0)