Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Avoid the need to specify each image individually in `load-img` (#1855)
Dhruv Bhanushali1b3438337fb4
diff --git a/.github/actions/load-img/action.yml b/.github/actions/load-img/action.ymlindex b9eb82104..0ad6f3494 100644--- a/.github/actions/load-img/action.yml+++ b/.github/actions/load-img/action.yml@@ -3,91 +3,41 @@ description: Download and import Docker images from artifactsinputs:setup_images:- default: '["upstream_db", "ingestion_server", "catalog", "api", "api_nginx", "frontend"]'- description: JSON-encoded list of image names+ default: "upstream_db ingestion_server catalog api api_nginx frontend"+ description: Space-separated list of image namesruns:using: "composite"steps:- # Upstream DB- - name: Download image `upstream_db`- uses: actions/download-artifact@v3- if: contains(fromJson(inputs.setup_images), 'upstream_db')- with:- name: upstream_db- path: /tmp-- - name: Load image `upstream_db`- if: contains(fromJson(inputs.setup_images), 'upstream_db')- shell: bash- run: |- docker load --input /tmp/upstream_db.tar-- # Catalog- - name: Download image `catalog`- uses: actions/download-artifact@v3- if: contains(fromJson(inputs.setup_images), 'catalog')- with:- name: catalog- path: /tmp-- - name: Load image `catalog`- if: contains(fromJson(inputs.setup_images), 'catalog')- shell: bash- run: |- docker load --input /tmp/catalog.tar-- # Ingestion server- - name: Download image `ingestion_server`- uses: actions/download-artifact@v3- if: contains(fromJson(inputs.setup_images), 'ingestion_server')- with:- name: ingestion_server- path: /tmp-- - name: Load image `ingestion_server`- if: contains(fromJson(inputs.setup_images), 'ingestion_server')- shell: bash- run: |- docker load --input /tmp/ingestion_server.tar-- # API- - name: Download image `api`- uses: actions/download-artifact@v3- if: contains(fromJson(inputs.setup_images), 'api')- with:- name: api- path: /tmp+ - name: Checkout repository+ uses: actions/checkout@v3- - name: Load image `api`- if: contains(fromJson(inputs.setup_images), 'api')- shell: bash- run: |- docker load --input /tmp/api.tar-- - name: Download image `api_nginx`- uses: actions/download-artifact@v3- if: contains(fromJson(inputs.setup_images), 'api_nginx')+ # Doesn't use `setup-env` because the next step uses `npm`, not `pnpm`.+ - name: Setup Node.js+ uses: actions/setup-node@v3with:- name: api_nginx- path: /tmp+ node-version: "16"- - name: Load image `api_nginx`- if: contains(fromJson(inputs.setup_images), 'api_nginx')+ - name: Install `@actions/artifact`shell: bashrun: |- docker load --input /tmp/api_nginx.tar+ npm install @actions/artifact- # Frontend- - name: Download image `frontend`- uses: actions/download-artifact@v3- if: contains(fromJson(inputs.setup_images), 'frontend')+ - name: Download images+ uses: actions/github-script@v6with:- name: frontend- path: /tmp-- - name: Load image `frontend`- if: contains(fromJson(inputs.setup_images), 'frontend')+ script: |+ const artifact = require("@actions/artifact")+ const artifactClient = artifact.create()+ const images = "${{ inputs.setup_images }}".split(" ")+ for (image of images) {+ await artifactClient.downloadArtifact(image, "/tmp", { createArtifactFolder: false })+ }++ - name: Load imagesshell: bashrun: |- docker load --input /tmp/frontend.tar+ images=(${{ inputs.setup_images }});+ for image in "${images[@]}"; do+ docker load --input /tmp/${image}.tar+ donediff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.ymlindex d3b10a247..858b8ed72 100644--- a/.github/workflows/ci_cd.yml+++ b/.github/workflows/ci_cd.yml@@ -252,7 +252,7 @@ jobs:- name: Load Docker imagesuses: ./.github/actions/load-imgwith:- setup_images: '["upstream_db", "catalog"]'+ setup_images: upstream_db catalog- name: Run testsrun: |@@ -281,7 +281,7 @@ jobs:- name: Load Docker imagesuses: ./.github/actions/load-imgwith:- setup_images: '["upstream_db", "catalog"]'+ setup_images: upstream_db catalog- name: Check DAG documentationrun: |@@ -315,7 +315,7 @@ jobs:- name: Load Docker imagesuses: ./.github/actions/load-imgwith:- setup_images: '["upstream_db", "ingestion_server"]'+ setup_images: upstream_db ingestion_server- name: Run ingestion-server testsrun: just ingestion_server/test-local@@ -360,7 +360,7 @@ jobs:- name: Load Docker imagesuses: ./.github/actions/load-imgwith:- setup_images: '["upstream_db", "ingestion_server", "api"]'+ setup_images: upstream_db ingestion_server api- name: Start API, ingest and index test datarun: just api/init@@ -413,7 +413,7 @@ jobs:- name: Load Docker imagesuses: ./.github/actions/load-imgwith:- setup_images: '["upstream_db", "ingestion_server", "api"]'+ setup_images: upstream_db ingestion_server api- name: Run check reciperun: just ${{ matrix.recipe }}@@ -798,7 +798,7 @@ jobs:- name: Load Docker image `${{ matrix.image }}`uses: ./.github/actions/load-imgwith:- setup_images: ${{ format('["{0}"]', matrix.image) }}+ setup_images: ${{ matrix.image }}- name: Load and tag image `${{ matrix.image }}` (latest & sha)run: |diff --git a/documentation/meta/ci_cd/actions.md b/documentation/meta/ci_cd/actions.mdindex 53d39cd4c..e896983ce 100644--- a/documentation/meta/ci_cd/actions.md+++ b/documentation/meta/ci_cd/actions.md@@ -59,13 +59,13 @@ downloads the artifact and load the `.tar` files into Docker as images.**Inputs:**-By default, all images built by the Docker system will be loaded but if the job-only needs a subset of images, those can be set via the `setup_images` input,-passing a JSON encoded array of image names as strings.+By default, all images built by the Docker system will be loaded. However, if+the job only needs a subset of images, those can be set via the `setup_images`+input, passing a space-separated list of image names.```typescript{- setup_images: string // default: '["upstream_db", "ingestion_server", "catalog", "api", "api_nginx", "frontend"]'+ setup_images: string // default: 'upstream_db ingestion_server catalog api api_nginx frontend'}```