|
| 1 | +name: Vercel Container Registry Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: Docker release version without the v prefix |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + source_refs: |
| 11 | + description: Newline-delimited alias=immutable-ref entries verified by the caller |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + include_browser: |
| 15 | + description: Whether the tagged Docker release includes browser images |
| 16 | + required: true |
| 17 | + type: boolean |
| 18 | + secrets: |
| 19 | + VERCEL_TOKEN: |
| 20 | + required: true |
| 21 | + |
| 22 | +env: |
| 23 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" |
| 24 | + NODE_VERSION: "24.15.0" |
| 25 | + |
| 26 | +concurrency: |
| 27 | + # Alias promotion is read-then-write. Serialize VCR independently so a slow |
| 28 | + # mirror never holds the Docker publication lock. |
| 29 | + group: vcr-release-publish |
| 30 | + cancel-in-progress: false |
| 31 | + |
| 32 | +jobs: |
| 33 | + publish: |
| 34 | + runs-on: ubuntu-24.04 |
| 35 | + timeout-minutes: 30 |
| 36 | + # VCR is a best-effort mirror. Failed steps remain visible, but the primary |
| 37 | + # Docker publication and GitHub release finalization must continue. |
| 38 | + continue-on-error: true |
| 39 | + permissions: |
| 40 | + contents: read |
| 41 | + steps: |
| 42 | + - name: Checkout trusted registry tooling |
| 43 | + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
| 44 | + with: |
| 45 | + ref: ${{ github.sha }} |
| 46 | + persist-credentials: false |
| 47 | + |
| 48 | + - name: Set up Docker Builder |
| 49 | + uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 |
| 50 | + |
| 51 | + - name: Setup trusted Node runtime |
| 52 | + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 |
| 53 | + with: |
| 54 | + node-version: ${{ env.NODE_VERSION }} |
| 55 | + |
| 56 | + # Materialize the complete CLI dependency closure before the production |
| 57 | + # token enters any step environment. The committed lock and integrity |
| 58 | + # checks keep registry and Sandbox operations on reviewed executable code. |
| 59 | + - name: Materialize locked Vercel CLI |
| 60 | + id: vercel_cli |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + bash scripts/materialize-vercel-cli.sh \ |
| 64 | + .github/release/vercel-cli \ |
| 65 | + "${RUNNER_TEMP}/vercel-cli" \ |
| 66 | + "${GITHUB_OUTPUT}" |
| 67 | +
|
| 68 | + - name: Validate Vercel Container Registry configuration |
| 69 | + env: |
| 70 | + VERCEL_PROJECT_ID: ${{ vars.VERCEL_PROJECT_ID }} |
| 71 | + VERCEL_SCOPE: ${{ vars.VERCEL_SCOPE }} |
| 72 | + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} |
| 73 | + VERCEL_VCR_IMAGE: ${{ vars.VERCEL_VCR_IMAGE }} |
| 74 | + run: | |
| 75 | + set -euo pipefail |
| 76 | + for name in VERCEL_PROJECT_ID VERCEL_SCOPE VERCEL_TOKEN VERCEL_VCR_IMAGE; do |
| 77 | + if [[ -z "${!name}" ]]; then |
| 78 | + echo "::error::${name} is required for Vercel Container Registry publishing." |
| 79 | + exit 1 |
| 80 | + fi |
| 81 | + done |
| 82 | + if [[ "${VERCEL_VCR_IMAGE}" != vcr.vercel.com/*/*/* ]]; then |
| 83 | + echo "::error::VERCEL_VCR_IMAGE must be a full vcr.vercel.com/team/project/repository image name." |
| 84 | + exit 1 |
| 85 | + fi |
| 86 | +
|
| 87 | + - name: Authenticate Docker to Vercel Container Registry |
| 88 | + env: |
| 89 | + VERCEL_CLI: ${{ steps.vercel_cli.outputs.cli }} |
| 90 | + VERCEL_PROJECT_ID: ${{ vars.VERCEL_PROJECT_ID }} |
| 91 | + VERCEL_SCOPE: ${{ vars.VERCEL_SCOPE }} |
| 92 | + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} |
| 93 | + run: | |
| 94 | + set -euo pipefail |
| 95 | + "${VERCEL_CLI}" vcr login docker \ |
| 96 | + --project "${VERCEL_PROJECT_ID}" \ |
| 97 | + --scope "${VERCEL_SCOPE}" \ |
| 98 | + --format json |
| 99 | +
|
| 100 | + - name: Copy and verify immutable release images |
| 101 | + id: copy_images |
| 102 | + env: |
| 103 | + INCLUDE_BROWSER: ${{ inputs.include_browser }} |
| 104 | + SOURCE_REFS: ${{ inputs.source_refs }} |
| 105 | + TARGET_IMAGE: ${{ vars.VERCEL_VCR_IMAGE }} |
| 106 | + VERSION: ${{ inputs.version }} |
| 107 | + run: | |
| 108 | + set -euo pipefail |
| 109 | + browser_args=() |
| 110 | + if [[ "${INCLUDE_BROWSER}" == "true" ]]; then |
| 111 | + browser_args+=(--include-browser) |
| 112 | + fi |
| 113 | + source_ref_args=() |
| 114 | + while IFS= read -r source_ref; do |
| 115 | + [[ -z "${source_ref}" ]] && continue |
| 116 | + source_ref_args+=(--source-ref "${source_ref}") |
| 117 | + done <<< "${SOURCE_REFS}" |
| 118 | + node scripts/vercel-container-registry-publish.mjs \ |
| 119 | + --version "${VERSION}" \ |
| 120 | + "${source_ref_args[@]}" \ |
| 121 | + --target-image "${TARGET_IMAGE}" \ |
| 122 | + "${browser_args[@]}" |
| 123 | +
|
| 124 | + # VCR tag status can remain null after an image is usable, so Sandbox |
| 125 | + # creation is the authoritative readiness check for this publication. |
| 126 | + - name: Run custom-image Sandbox smoke |
| 127 | + id: sandbox_smoke |
| 128 | + env: |
| 129 | + VERCEL_AUTH_TOKEN: ${{ secrets.VERCEL_TOKEN }} |
| 130 | + VERCEL_CLI: ${{ steps.vercel_cli.outputs.cli }} |
| 131 | + VERCEL_PROJECT_ID: ${{ vars.VERCEL_PROJECT_ID }} |
| 132 | + VERCEL_SCOPE: ${{ vars.VERCEL_SCOPE }} |
| 133 | + VERCEL_VCR_IMAGE: ${{ vars.VERCEL_VCR_IMAGE }} |
| 134 | + VERSION: ${{ inputs.version }} |
| 135 | + run: | |
| 136 | + set -euo pipefail |
| 137 | + repository="${VERCEL_VCR_IMAGE##*/}" |
| 138 | + retry_deadline=$((SECONDS + 600)) |
| 139 | + attempt=1 |
| 140 | + while true; do |
| 141 | + set +e |
| 142 | + output="$( |
| 143 | + "${VERCEL_CLI}" sandbox run \ |
| 144 | + --silent \ |
| 145 | + --rm \ |
| 146 | + --non-persistent \ |
| 147 | + --network-policy deny-all \ |
| 148 | + --timeout 3m \ |
| 149 | + --project "${VERCEL_PROJECT_ID}" \ |
| 150 | + --scope "${VERCEL_SCOPE}" \ |
| 151 | + --image "${repository}:${VERSION}" \ |
| 152 | + --workdir /app \ |
| 153 | + --env "EXPECTED_VERSION=${VERSION}" \ |
| 154 | + -- /bin/sh -lc 'test "$(node -p "require(\"./package.json\").version")" = "${EXPECTED_VERSION}" && node openclaw.mjs --version' \ |
| 155 | + 2>&1 |
| 156 | + )" |
| 157 | + status=$? |
| 158 | + set -e |
| 159 | + printf '%s\n' "${output}" |
| 160 | + if [[ "${status}" -eq 0 ]]; then |
| 161 | + break |
| 162 | + fi |
| 163 | + if [[ "${output}" != *"image_not_ready"* ]]; then |
| 164 | + exit "${status}" |
| 165 | + fi |
| 166 | + if (( SECONDS >= retry_deadline )); then |
| 167 | + echo "::error::Vercel image preparation remained image_not_ready for 10 minutes." |
| 168 | + exit "${status}" |
| 169 | + fi |
| 170 | + delay=10 |
| 171 | + remaining=$((retry_deadline - SECONDS)) |
| 172 | + if (( delay > remaining )); then |
| 173 | + delay="${remaining}" |
| 174 | + fi |
| 175 | + echo "::notice::Vercel image is not ready; retrying Sandbox smoke in ${delay}s (attempt ${attempt})." |
| 176 | + sleep "${delay}" |
| 177 | + attempt=$((attempt + 1)) |
| 178 | + done |
| 179 | +
|
| 180 | + - name: Promote and verify channel aliases |
| 181 | + id: promote_aliases |
| 182 | + env: |
| 183 | + INCLUDE_BROWSER: ${{ inputs.include_browser }} |
| 184 | + TARGET_IMAGE: ${{ vars.VERCEL_VCR_IMAGE }} |
| 185 | + VERSION: ${{ inputs.version }} |
| 186 | + run: | |
| 187 | + set -euo pipefail |
| 188 | + browser_args=() |
| 189 | + if [[ "${INCLUDE_BROWSER}" == "true" ]]; then |
| 190 | + browser_args+=(--include-browser) |
| 191 | + fi |
| 192 | + node scripts/vercel-container-registry-publish.mjs \ |
| 193 | + --version "${VERSION}" \ |
| 194 | + --target-image "${TARGET_IMAGE}" \ |
| 195 | + --promote-aliases \ |
| 196 | + "${browser_args[@]}" |
| 197 | +
|
| 198 | + - name: Summarize Vercel publication |
| 199 | + if: ${{ always() }} |
| 200 | + env: |
| 201 | + COPY_OUTCOME: ${{ steps.copy_images.outcome }} |
| 202 | + INCLUDE_BROWSER: ${{ inputs.include_browser }} |
| 203 | + PROMOTE_OUTCOME: ${{ steps.promote_aliases.outcome }} |
| 204 | + SMOKE_OUTCOME: ${{ steps.sandbox_smoke.outcome }} |
| 205 | + TARGET_IMAGE: ${{ vars.VERCEL_VCR_IMAGE }} |
| 206 | + VERSION: ${{ inputs.version }} |
| 207 | + run: | |
| 208 | + variants="default, slim" |
| 209 | + if [[ "${INCLUDE_BROWSER}" == "true" ]]; then |
| 210 | + variants="${variants}, browser" |
| 211 | + fi |
| 212 | + status="passed" |
| 213 | + if [[ "${COPY_OUTCOME}" != "success" || "${SMOKE_OUTCOME}" != "success" || "${PROMOTE_OUTCOME}" != "success" ]]; then |
| 214 | + status="failed (non-blocking)" |
| 215 | + echo "::warning::VCR mirror failed; Docker publication and GitHub release finalization are unaffected." |
| 216 | + fi |
| 217 | + { |
| 218 | + echo "## Vercel Container Registry" |
| 219 | + echo "- Image: ${TARGET_IMAGE}:${VERSION}" |
| 220 | + echo "- Variants: ${variants}" |
| 221 | + echo "- Platforms: linux/amd64, linux/arm64" |
| 222 | + echo "- Status: ${status}" |
| 223 | + echo "- Copy: ${COPY_OUTCOME}" |
| 224 | + echo "- Sandbox smoke: ${SMOKE_OUTCOME}" |
| 225 | + echo "- Alias promotion: ${PROMOTE_OUTCOME}" |
| 226 | + } >> "${GITHUB_STEP_SUMMARY}" |
0 commit comments