-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci) cache httpbin docker image
CI has been failing rather frequently due to Docker registry returning `502 Bad Gateway` when the `setup-httpbin-server` action attempts to pull httpbin's docker image. In fact, this image has been pulled by 16 jobs (Unit and Valgrind) for every GHA workflow run. This might explain why we eventually fail to pull it. Caching it should greatly reduce the number of times httpbin image is actually pulled, which should prevent us from being rate limited.
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: load-docker-image | ||
decription: | | ||
Pull a docker image and cache it. | ||
inputs: | ||
image: | ||
required: true | ||
type: string | ||
cache_dir: | ||
required: false | ||
type: string | ||
default: "~/.docker-images-cache" | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Create cache directory | ||
shell: bash | ||
run: mkdir -p ${{ inputs.cache_dir }} | ||
|
||
- name: Setup cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ inputs.cache_dir }} | ||
key: pulled-docker-images | ||
|
||
- name: Setup cache path | ||
id: cache_setup | ||
shell: bash | ||
run: | | ||
filename="$(echo ${{ inputs.image }} | sed 's/\//_/g').tar" | ||
cache_path="${{ inputs.cache_dir }}/$filename" | ||
if [ -f "$cache_path" ]; then | ||
echo "cache_hit=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "cache_hit=false" >> $GITHUB_OUTPUT | ||
fi | ||
echo "cache_path=$cache_path" >> $GITHUB_OUTPUT | ||
- name: Pull Docker image | ||
if: steps.cache_setup.outputs.cache_hit == 'false' | ||
shell: bash | ||
run: | | ||
docker pull ${{ inputs.image }} | ||
docker save -o ${{ steps.cache_setup.outputs.cache_path }} ${{ inputs.image }} | ||
- name: Load Docker image from cache | ||
if: steps.cache_setup.outputs.cache-hit == 'true' | ||
shell: bash | ||
run: docker load -i ${{ steps.cache_setup.outputs.cache_path }} |
This file contains 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