Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | name: 'Build E2E Docker image' |
| 2 | description: 'Builds an E2E test image with Buildx, restoring and saving layers through the GitHub Actions cache' |
| 3 | |
| 4 | inputs: |
| 5 | dockerfile: |
| 6 | description: 'Path to the Dockerfile, relative to the repository root' |
| 7 | required: true |
| 8 | tag: |
| 9 | description: >- |
| 10 | Tag for the image loaded into the local Docker daemon. Unused (nothing is |
| 11 | loaded) when cache-only is 'true'. |
| 12 | required: false |
| 13 | default: '' |
| 14 | cache-scope: |
| 15 | description: 'GitHub Actions cache scope. Use one scope per image variant so matrix jobs do not overwrite each other' |
| 16 | required: true |
| 17 | cache-target: |
| 18 | description: >- |
| 19 | Build stage whose layers are saved to the cache. Set it on images that |
| 20 | copy the workspace in later stages: those layers change on every commit, |
| 21 | so saving them would only evict caches that do get restored. Leave empty |
| 22 | to save every layer. |
| 23 | required: false |
| 24 | default: '' |
| 25 | cache-only: |
| 26 | description: >- |
| 27 | 'true' skips the final image build and only refreshes the cache-target |
| 28 | stage in the GitHub Actions cache. For prewarm callers whose checkout |
| 29 | cannot provide the workspace artifacts the later stages COPY (host-built |
| 30 | dist under ts/packages), so the final build would fail anyway. Only |
| 31 | meaningful together with cache-target. |
| 32 | required: false |
| 33 | default: 'false' |
| 34 | build-args: |
| 35 | description: 'Newline-separated KEY=VALUE build arguments' |
| 36 | required: false |
| 37 | default: '' |
| 38 | labels: |
| 39 | description: 'Newline-separated KEY=VALUE image labels' |
| 40 | required: false |
| 41 | default: '' |
| 42 | build-retries: |
| 43 | description: >- |
| 44 | Number of build attempts per build: '1', '2' or '3' (one |
| 45 | build-push-action step per attempt). Base-image resolution from ECR |
| 46 | Public can fail with HTTP 429 anonymous rate limits on shared runner |
| 47 | IPs; failed builds are retried after a delay, and a final retry also |
| 48 | overrides BASE_REGISTRY to mirror.gcr.io, whose Docker Official Image |
| 49 | digests are byte-identical to the pins in ts/e2e-tests/_utils/Dockerfile.*. |
| 50 | required: false |
| 51 | default: '3' |
| 52 | |
| 53 | runs: |
| 54 | using: 'composite' |
| 55 | steps: |
| 56 | # The default `docker` driver cannot export to the GitHub Actions cache. |
| 57 | - name: Set up Docker Buildx |
| 58 | uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 |
| 59 | |
| 60 | - name: Validate build-retries |
| 61 | if: inputs.build-retries != '1' && inputs.build-retries != '2' && inputs.build-retries != '3' |
| 62 | shell: bash |
| 63 | run: | |
| 64 | echo "::error::build-retries must be '1', '2' or '3', got '${{ inputs.build-retries }}'" |
| 65 | exit 1 |
| 66 | |
| 67 | # The builds must stay inside `uses:` steps: docker/build-push-action |
| 68 | # receives the GitHub cache credentials (ACTIONS_RUNTIME_TOKEN and the |
| 69 | # cache URL) that buildx's `type=gha` backend needs and that plain `run:` |
| 70 | # steps do not get, so raw `docker buildx build` here silently skips cache |
| 71 | # import and export. Retries are chained on the previous attempt's |
| 72 | # `outcome`; `continue-on-error` is expression-driven so a final attempt |
| 73 | # still fails the action. The last retry also overrides BASE_REGISTRY to |
| 74 | # mirror.gcr.io (build args are last-wins): its digest-pinned manifests are |
| 75 | # byte-identical to the ECR Public pins, so persistent ECR 429s can be |
| 76 | # cleared from a different IP pool. |
| 77 | |
| 78 | - name: Build and cache the ${{ inputs.cache-target }} stage (attempt 1) |
| 79 | id: cache-stage-attempt-1 |
| 80 | if: inputs.cache-target != '' |
| 81 | continue-on-error: ${{ inputs.build-retries != '1' }} |
| 82 | uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 |
| 83 | env: |
| 84 | DOCKER_BUILD_SUMMARY: 'false' |
| 85 | DOCKER_BUILD_RECORD_UPLOAD: 'false' |
| 86 | with: |
| 87 | context: . |
| 88 | file: ${{ inputs.dockerfile }} |
| 89 | target: ${{ inputs.cache-target }} |
| 90 | build-args: ${{ inputs.build-args }} |
| 91 | provenance: false |
| 92 | outputs: type=cacheonly |
| 93 | cache-from: type=gha,scope=${{ inputs.cache-scope }} |
| 94 | # `ignore-error` keeps a cache-service outage from failing the build. |
| 95 | cache-to: type=gha,scope=${{ inputs.cache-scope }},mode=max,ignore-error=true |
| 96 | |
| 97 | - name: Wait before retrying the ${{ inputs.cache-target }} stage |
| 98 | if: inputs.cache-target != '' && steps.cache-stage-attempt-1.outcome == 'failure' && inputs.build-retries != '1' |
| 99 | shell: bash |
| 100 | run: sleep 10 |
| 101 | |
| 102 | - name: Build and cache the ${{ inputs.cache-target }} stage (attempt 2) |
| 103 | id: cache-stage-attempt-2 |
| 104 | if: inputs.cache-target != '' && steps.cache-stage-attempt-1.outcome == 'failure' && inputs.build-retries != '1' |
| 105 | continue-on-error: ${{ inputs.build-retries == '3' }} |
| 106 | uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 |
| 107 | env: |
| 108 | DOCKER_BUILD_SUMMARY: 'false' |
| 109 | DOCKER_BUILD_RECORD_UPLOAD: 'false' |
| 110 | with: |
| 111 | context: . |
| 112 | file: ${{ inputs.dockerfile }} |
| 113 | target: ${{ inputs.cache-target }} |
| 114 | build-args: ${{ inputs.build-args }} |
| 115 | provenance: false |
| 116 | outputs: type=cacheonly |
| 117 | cache-from: type=gha,scope=${{ inputs.cache-scope }} |
| 118 | # `ignore-error` keeps a cache-service outage from failing the build. |
| 119 | cache-to: type=gha,scope=${{ inputs.cache-scope }},mode=max,ignore-error=true |
| 120 | |
| 121 | - name: Wait before the final ${{ inputs.cache-target }} stage attempt |
| 122 | if: inputs.cache-target != '' && steps.cache-stage-attempt-2.outcome == 'failure' && inputs.build-retries == '3' |
| 123 | shell: bash |
| 124 | run: sleep 20 |
| 125 | |
| 126 | - name: Build and cache the ${{ inputs.cache-target }} stage (final attempt, mirror.gcr.io fallback) |
| 127 | if: inputs.cache-target != '' && steps.cache-stage-attempt-2.outcome == 'failure' && inputs.build-retries == '3' |
| 128 | uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 |
| 129 | env: |
| 130 | DOCKER_BUILD_SUMMARY: 'false' |
| 131 | DOCKER_BUILD_RECORD_UPLOAD: 'false' |
| 132 | with: |
| 133 | context: . |
| 134 | file: ${{ inputs.dockerfile }} |
| 135 | target: ${{ inputs.cache-target }} |
| 136 | build-args: | |
| 137 | ${{ inputs.build-args }} |
| 138 | BASE_REGISTRY=mirror.gcr.io/library |
| 139 | provenance: false |
| 140 | outputs: type=cacheonly |
| 141 | cache-from: type=gha,scope=${{ inputs.cache-scope }} |
| 142 | # `ignore-error` keeps a cache-service outage from failing the build. |
| 143 | cache-to: type=gha,scope=${{ inputs.cache-scope }},mode=max,ignore-error=true |
| 144 | |
| 145 | # The final image build is skipped in cache-only mode: its later stages |
| 146 | # COPY workspace files (including host-built dist) that a cache-refreshing |
| 147 | # caller may not have, and its layers rebuild from the cached stage anyway. |
| 148 | |
| 149 | - name: Build ${{ inputs.tag }} (attempt 1) |
| 150 | id: image-attempt-1 |
| 151 | if: inputs.cache-target == '' || inputs.cache-only != 'true' |
| 152 | continue-on-error: ${{ inputs.build-retries != '1' }} |
| 153 | uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 |
| 154 | env: |
| 155 | DOCKER_BUILD_SUMMARY: 'false' |
| 156 | DOCKER_BUILD_RECORD_UPLOAD: 'false' |
| 157 | with: |
| 158 | context: . |
| 159 | file: ${{ inputs.dockerfile }} |
| 160 | build-args: ${{ inputs.build-args }} |
| 161 | labels: ${{ inputs.labels }} |
| 162 | tags: ${{ inputs.tag }} |
| 163 | provenance: false |
| 164 | load: true |
| 165 | cache-from: type=gha,scope=${{ inputs.cache-scope }} |
| 166 | cache-to: ${{ inputs.cache-target == '' && format('type=gha,scope={0},mode=max,ignore-error=true', inputs.cache-scope) || '' }} |
| 167 | |
| 168 | - name: Wait before retrying the ${{ inputs.tag }} build |
| 169 | if: (inputs.cache-target == '' || inputs.cache-only != 'true') && steps.image-attempt-1.outcome == 'failure' && inputs.build-retries != '1' |
| 170 | shell: bash |
| 171 | run: sleep 10 |
| 172 | |
| 173 | - name: Build ${{ inputs.tag }} (attempt 2) |
| 174 | id: image-attempt-2 |
| 175 | if: (inputs.cache-target == '' || inputs.cache-only != 'true') && steps.image-attempt-1.outcome == 'failure' && inputs.build-retries != '1' |
| 176 | continue-on-error: ${{ inputs.build-retries == '3' }} |
| 177 | uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 |
| 178 | env: |
| 179 | DOCKER_BUILD_SUMMARY: 'false' |
| 180 | DOCKER_BUILD_RECORD_UPLOAD: 'false' |
| 181 | with: |
| 182 | context: . |
| 183 | file: ${{ inputs.dockerfile }} |
| 184 | build-args: ${{ inputs.build-args }} |
| 185 | labels: ${{ inputs.labels }} |
| 186 | tags: ${{ inputs.tag }} |
| 187 | provenance: false |
| 188 | load: true |
| 189 | cache-from: type=gha,scope=${{ inputs.cache-scope }} |
| 190 | cache-to: ${{ inputs.cache-target == '' && format('type=gha,scope={0},mode=max,ignore-error=true', inputs.cache-scope) || '' }} |
| 191 | |
| 192 | - name: Wait before the final ${{ inputs.tag }} build attempt |
| 193 | if: (inputs.cache-target == '' || inputs.cache-only != 'true') && steps.image-attempt-2.outcome == 'failure' && inputs.build-retries == '3' |
| 194 | shell: bash |
| 195 | run: sleep 20 |
| 196 | |
| 197 | - name: Build ${{ inputs.tag }} (final attempt, mirror.gcr.io fallback) |
| 198 | if: (inputs.cache-target == '' || inputs.cache-only != 'true') && steps.image-attempt-2.outcome == 'failure' && inputs.build-retries == '3' |
| 199 | uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 |
| 200 | env: |
| 201 | DOCKER_BUILD_SUMMARY: 'false' |
| 202 | DOCKER_BUILD_RECORD_UPLOAD: 'false' |
| 203 | with: |
| 204 | context: . |
| 205 | file: ${{ inputs.dockerfile }} |
| 206 | build-args: | |
| 207 | ${{ inputs.build-args }} |
| 208 | BASE_REGISTRY=mirror.gcr.io/library |
| 209 | labels: ${{ inputs.labels }} |
| 210 | tags: ${{ inputs.tag }} |
| 211 | provenance: false |
| 212 | load: true |
| 213 | cache-from: type=gha,scope=${{ inputs.cache-scope }} |
| 214 | cache-to: ${{ inputs.cache-target == '' && format('type=gha,scope={0},mode=max,ignore-error=true', inputs.cache-scope) || '' }} |