Container Image Artifact¶
This workflow is used to upload container images as artifacts during a workflow.
This is useful for 'caching' an downloaded image, if it if used again within the same workflow, preventing repeated pulls.
This may or may not be faster than pulling the image again, as the image still has to pull from thr artifact API.
However, it does prevent repeated pull from container registries where rate limiting is applied (e.g. dockerhub).
Note: this strategy does not work across workflow runs.
Inputs¶
INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
---|---|---|---|---|
image_names | string | true | A space separated list of full image names to upload, including tag. |
Outputs¶
OUTPUT | VALUE | DESCRIPTION |
---|---|---|
artifact_name | "images" |
The artifact name (default: artifact ). |
Secrets¶
No secrets.
Example Usage¶
In this example, we cache various dependent images, to prevent download every time pytest is run.
jobs:
artifact-imgs:
uses: hotosm/gh-workflows/.github/workflows/image_artifact.yml@main
with:
image_names: |
docker.io/postgis/postgis:${{ vars.POSTGIS_TAG }}
ghcr.io/hotosm/fmtm/odkcentral:${{ vars.ODK_CENTRAL_TAG }}
ghcr.io/hotosm/fmtm/odkcentral-proxy:${{ vars.ODK_CENTRAL_TAG }}
docker.io/minio/minio:${{ vars.MINIO_TAG }}
run-pytest:
runs-on: ubuntu-latest
needs: [artifact-imgs]
environment:
name: ${{ inputs.environment || 'test' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Images Tars
id: download-images
uses: actions/download-artifact@v4
with:
path: /tmp/images
- name: Load Tar Imgs
run: |
for image_tar in /tmp/images/*; do
docker image load --input $image_tar || true
done
- name: Run PyTest
run: |
docker compose run api \
wait-for-it fmtm-db:5432 --strict \
-- wait-for-it central:8383 --strict --timeout=30 \
-- pytest