diff --git a/.github/actions/setup-httpbin-server/action.yml b/.github/actions/setup-httpbin-server/action.yml index f7d85cfb3..175b9b028 100644 --- a/.github/actions/setup-httpbin-server/action.yml +++ b/.github/actions/setup-httpbin-server/action.yml @@ -36,12 +36,14 @@ runs: sudo apt-get update sudo apt-get install -y dnsmasq + - name: 'Setup deps - macOS' if: ${{ contains(inputs.os, 'macos') }} shell: bash run: | brew install dnsmasq docker colima colima start --network-address + - name: Setup Docker image tag id: setup shell: bash @@ -54,6 +56,7 @@ runs: echo "push=false" >> $GITHUB_OUTPUT echo "tag=wasmx-ci-httpbin-proxy:latest" >> $GITHUB_OUTPUT fi + - name: Login to GitHub Container Registry if: ${{ steps.setup.outputs.push == 'true' }} uses: docker/login-action@v3 @@ -61,9 +64,11 @@ runs: registry: ghcr.io username: ${{ inputs.ghcr_username }} password: ${{ inputs.ghcr_password }} + - name: Setup Docker Buildx if: ${{ !env.ACT }} uses: docker/setup-buildx-action@v3 + - name: Build httpbin-proxy image uses: docker/build-push-action@v5 with: @@ -74,6 +79,32 @@ runs: context: . cache-from: type=gha cache-to: type=gha,mode=max + + # Cache httpbin docker image to prevent abusing Docker registry + + - name: Create cache directory for httpbin Docker image + shell: bash + run: mkdir -p ~/image-cache + + - name: Setup httpbin Docker image cache + id: image-cache + uses: actions/cache@v4 + with: + path: ~/image-cache + key: httpbin-docker-image + + - name: Pull httpbin Docker image + if: steps.image-cache.outputs.cache-hit != 'true' + shell: bash + run: | + docker pull kennethreitz/httpbin + docker save -o ~/image-cache/httpbin.tar kennethreitz/httpbin + + - name: Load httpbin Docker image from cache + if: steps.image-cache.outputs.cache-hit == 'true' + shell: bash + run: docker load -i ~/image-cache/httpbin.tar + - name: Start dnsmasq shell: bash run: | @@ -83,6 +114,7 @@ runs: --server=${{ inputs.upstream_dns_server }} \ --address=/httpbin.org/127.0.0.1 \ --address=/example.com/127.0.0.1 + - name: Start httpbin proxy + server shell: bash run: |