mirror of
https://github.com/penpot/penpot.git
synced 2026-11-29 06:30:33 +00:00
✨ Build preview image sets into their own registry
Preview environments run on their own cluster, which cannot reuse the published registry: every pull would cross a network boundary that costs money, and the cluster would have to hold credentials that rotate. So previews publish to a registry of their own. build-docker.yml gains preview, platforms, images, attestations and move_branch_tags, every one of them defaulting to exactly what happens today. _DEVELOP, _STAGING, _TAG and _ADHOC produce the same artefacts as before. The registry address comes from the PREVIEW_REGISTRY_URL secret rather than travelling as a parameter. Two registries keep the image tags apart on their own: the build key comes from the commit and the version, not the branch, so a preview and a published build of the same commit would otherwise write the same tag. The bucket is shared, though, and the completion marker lives there. A preview writing the canonical marker would make a later published build of that commit skip its work and leave production without arm64, so previews write their own. The canonical key keeps its current shape, so the markers already in S3 stay valid and nothing is rebuilt when this lands. move_branch_tags is the other guard. A preview that moved them would repoint the tags the fixed environments deploy from. The admin-console dispatcher propagates the same settings and retrieves the built reference from the artifact nitrate publishes, since a dispatched run cannot return outputs across repositories. _PREVIEW fixes all of it rather than exposing it: the chatops will run this many times a day, and a wrong value produces an environment that fails in ways nobody can explain. _ADHOC stays as the way to build an arbitrary branch for the fixed environments. The bundle is untouched. It is keyed by commit and version, so a preview of a ref already bundled compiles nothing, and it is the identical artefact a published build would use. The concurrency group carries the mode as well. Without it a preview and a release build of the same ref land in the same group with cancel-in-progress, so one kills the other and the dead run can leave images pushed with no marker. The inputs that change what gets built are reachable only through workflow_call. The marker records the commit, not the image set or the architectures, so a manual run with fewer images would let a later full build skip its work; each caller fixes them instead. The image list is validated before the matrix is built, so a bad value fails where it was given rather than as a missing Dockerfile. AI-assisted-by: claude-opus-5 Signed-off-by: David Barragán Merino <david.barragan@kaleidos.net>
This commit is contained in:
parent
c3ce46ed9a
commit
151b408877
75
.github/workflows/build-docker-admin-console.yml
vendored
75
.github/workflows/build-docker-admin-console.yml
vendored
@ -4,39 +4,70 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
gh_ref:
|
||||
description: 'Name of the branch or ref to build in penpot-nitrate'
|
||||
description: 'Name of the branch or ref to build admin-console from'
|
||||
type: string
|
||||
required: true
|
||||
default: 'develop'
|
||||
dispatch_ref:
|
||||
description: 'Branch of penpot-nitrate from which the workflow definition is read'
|
||||
description: 'Branch the admin-console workflow definition is read from'
|
||||
type: string
|
||||
required: false
|
||||
default: 'develop'
|
||||
force:
|
||||
description: 'Rebuild and overwrite even if already built'
|
||||
description: 'Rebuild even if this commit was already built'
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
|
||||
# preview, platforms and attestations are not exposed here: they change
|
||||
# what gets built, and a manual run should always produce the usual
|
||||
# artefacts. Callers set them through workflow_call.
|
||||
workflow_call:
|
||||
inputs:
|
||||
gh_ref:
|
||||
description: 'Name of the branch or ref to build in penpot-nitrate'
|
||||
description: 'Name of the branch or ref to build admin-console from'
|
||||
type: string
|
||||
required: true
|
||||
dispatch_ref:
|
||||
description: 'Branch of penpot-nitrate from which the workflow definition is read'
|
||||
description: 'Branch the admin-console workflow definition is read from'
|
||||
type: string
|
||||
required: false
|
||||
default: 'develop'
|
||||
force:
|
||||
description: 'Rebuild and overwrite even if already built'
|
||||
description: 'Rebuild even if this commit was already built'
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
preview:
|
||||
description: >-
|
||||
When true, the images are pushed to the preview registry instead of
|
||||
the usual one.
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
platforms:
|
||||
description: >-
|
||||
Architectures to build the images for. Both are needed for anything
|
||||
deployed or published; a preview only needs linux/amd64.
|
||||
type: string
|
||||
required: false
|
||||
default: 'linux/amd64,linux/arm64'
|
||||
attestations:
|
||||
description: >-
|
||||
When true, an SBOM and provenance data are attached to each image.
|
||||
Needed for anything published, and it makes the build slower.
|
||||
type: boolean
|
||||
required: false
|
||||
default: true
|
||||
outputs:
|
||||
image:
|
||||
description: >-
|
||||
Exact reference of the admin-console image, so the caller can
|
||||
deploy that one rather than a branch tag
|
||||
value: ${{ jobs.build-nitrate-docker.outputs.image }}
|
||||
secrets:
|
||||
ORG_WORKFLOW_TOKEN:
|
||||
description: 'Token with Actions write access on penpot-nitrate'
|
||||
description: 'Token with Actions write access on the admin-console repo'
|
||||
required: true
|
||||
|
||||
permissions: {}
|
||||
@ -44,6 +75,8 @@ permissions: {}
|
||||
jobs:
|
||||
build-nitrate-docker:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
image: ${{ steps.image.outputs.image }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.ORG_WORKFLOW_TOKEN }}
|
||||
REPO: penpot/penpot-nitrate
|
||||
@ -51,8 +84,11 @@ jobs:
|
||||
GH_REF: ${{ inputs.gh_ref }}
|
||||
DISPATCH_REF: ${{ inputs.dispatch_ref }}
|
||||
FORCE: ${{ inputs.force }}
|
||||
PREVIEW: ${{ inputs.preview }}
|
||||
PLATFORMS: ${{ inputs.platforms }}
|
||||
ATTESTATIONS: ${{ inputs.attestations }}
|
||||
steps:
|
||||
- name: Trigger nitrate docker build
|
||||
- name: Trigger the admin-console build
|
||||
id: dispatch
|
||||
run: |
|
||||
DISTINCT_ID="${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
@ -61,6 +97,9 @@ jobs:
|
||||
gh workflow run "$WORKFLOW" --repo "$REPO" --ref "$DISPATCH_REF" \
|
||||
-f gh_ref="$GH_REF" \
|
||||
-f force="$FORCE" \
|
||||
-f preview="$PREVIEW" \
|
||||
-f platforms="$PLATFORMS" \
|
||||
-f attestations="$ATTESTATIONS" \
|
||||
-f caller_run_id="$DISTINCT_ID" \
|
||||
-f caller_run_url="$CALLER_URL"
|
||||
|
||||
@ -83,9 +122,9 @@ jobs:
|
||||
RUN_URL="https://github.com/$REPO/actions/runs/$RUN_ID"
|
||||
echo "run_id=$RUN_ID" >> "$GITHUB_OUTPUT"
|
||||
echo "run_url=$RUN_URL" >> "$GITHUB_OUTPUT"
|
||||
echo "::notice title=Nitrate docker build::$RUN_URL"
|
||||
echo "::notice title=admin-console build::$RUN_URL"
|
||||
|
||||
- name: Wait for nitrate docker build
|
||||
- name: Wait for the admin-console build
|
||||
env:
|
||||
RUN_ID: ${{ steps.dispatch.outputs.run_id }}
|
||||
run: |
|
||||
@ -94,6 +133,20 @@ jobs:
|
||||
--interval 30 \
|
||||
--exit-status
|
||||
|
||||
# A dispatched run cannot return outputs, so the admin-console build
|
||||
# leaves the exact image reference in an artifact. Using the branch tag
|
||||
# instead would deploy whatever was pushed there last.
|
||||
- name: Fetch the built image reference
|
||||
id: image
|
||||
env:
|
||||
RUN_ID: ${{ steps.dispatch.outputs.run_id }}
|
||||
run: |
|
||||
gh run download "$RUN_ID" --repo "$REPO" \
|
||||
--name admin-console-build-key --dir ./build-key
|
||||
IMAGE=$(cat ./build-key/build-key.txt)
|
||||
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
|
||||
echo "::notice title=admin-console image::$IMAGE"
|
||||
|
||||
- name: Report result
|
||||
if: always() && steps.dispatch.outputs.run_id != ''
|
||||
env:
|
||||
@ -103,7 +156,7 @@ jobs:
|
||||
CONCLUSION=$(gh run view "$RUN_ID" \
|
||||
--repo "$REPO" --json conclusion --jq '.conclusion')
|
||||
{
|
||||
echo "### 🐳 Nitrate docker build"
|
||||
echo "### 🐳 admin-console build"
|
||||
echo ""
|
||||
echo "- Result: \`${CONCLUSION:-in_progress}\`"
|
||||
echo "- Run: ${RUN_URL}"
|
||||
|
||||
186
.github/workflows/build-docker.yml
vendored
186
.github/workflows/build-docker.yml
vendored
@ -9,10 +9,16 @@ on:
|
||||
required: true
|
||||
default: 'develop'
|
||||
force:
|
||||
description: 'Rebuild and overwrite even if this sha is already promoted'
|
||||
description: 'Rebuild even if this commit was already built'
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
|
||||
# preview, platforms, images, attestations and move_branch_tags are
|
||||
# deliberately not exposed here. They change what gets built, and the
|
||||
# completion marker only records the commit, so a manual run with
|
||||
# non-default values would let a later full build skip its work. They
|
||||
# are reachable through workflow_call, where each caller fixes them.
|
||||
workflow_call:
|
||||
inputs:
|
||||
gh_ref:
|
||||
@ -21,17 +27,59 @@ on:
|
||||
required: true
|
||||
sha:
|
||||
description: >-
|
||||
Exact commit to check out (full 40-char SHA, e.g. from
|
||||
build-bundle.yml). Falls back to gh_ref when empty; gh_ref
|
||||
always still names the branch tag to move.
|
||||
Exact commit to build, normally taken from build-bundle so that
|
||||
both build the same thing. Falls back to gh_ref when empty; the
|
||||
branch tag to move always comes from gh_ref.
|
||||
type: string
|
||||
required: false
|
||||
default: ''
|
||||
force:
|
||||
description: 'Rebuild and overwrite even if this sha is already promoted'
|
||||
description: 'Rebuild even if this commit was already built'
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
preview:
|
||||
description: >-
|
||||
When true, the images are pushed to the preview registry instead of
|
||||
the usual one.
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
platforms:
|
||||
description: >-
|
||||
Architectures to build the images for. Both are needed for anything
|
||||
deployed or published; a preview only needs linux/amd64.
|
||||
type: string
|
||||
required: false
|
||||
default: 'linux/amd64,linux/arm64'
|
||||
images:
|
||||
description: >-
|
||||
Which images to build, space separated. Defaults to all of them.
|
||||
type: string
|
||||
required: false
|
||||
default: 'backend frontend exporter storybook mcp'
|
||||
attestations:
|
||||
description: >-
|
||||
When true, an SBOM and provenance data are attached to each image.
|
||||
Needed for anything published, and it makes the build slower.
|
||||
type: boolean
|
||||
required: false
|
||||
default: true
|
||||
move_branch_tags:
|
||||
description: >-
|
||||
When true, the branch tag (backend:develop and so on) is repointed
|
||||
to this build. Previews leave it alone, so that they never change
|
||||
what the fixed environments deploy.
|
||||
type: boolean
|
||||
required: false
|
||||
default: true
|
||||
outputs:
|
||||
build_key:
|
||||
description: 'Tag the images were published under'
|
||||
value: ${{ jobs.prepare.outputs.build_key }}
|
||||
registry:
|
||||
description: 'Registry the images were published to'
|
||||
value: ${{ jobs.prepare.outputs.registry }}
|
||||
secrets:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
required: false
|
||||
@ -47,6 +95,12 @@ on:
|
||||
required: false
|
||||
MATTERMOST_WEBHOOK:
|
||||
required: false
|
||||
PREVIEW_REGISTRY_PASSWORD:
|
||||
required: false
|
||||
PREVIEW_REGISTRY_URL:
|
||||
required: false
|
||||
PREVIEW_REGISTRY_USERNAME:
|
||||
required: false
|
||||
PUB_DOCKER_PASSWORD:
|
||||
required: false
|
||||
PUB_DOCKER_USERNAME:
|
||||
@ -58,12 +112,15 @@ on:
|
||||
# caller's workflow, which put this workflow and the other reusable one called
|
||||
# by the same caller into a single shared group, and left a manual dispatch of
|
||||
# the same ref in a group of its own, free to race on the same artifacts.
|
||||
# The mode is part of the group. Without it a preview and a published build
|
||||
# of the same ref cancel each other, and the one that dies can leave images
|
||||
# pushed with no marker.
|
||||
concurrency:
|
||||
group: build-docker-${{ inputs.gh_ref }}
|
||||
group: build-docker-${{ inputs.preview && 'preview' || 'published' }}-${{ inputs.gh_ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
ALL_IMAGES: backend frontend exporter storybook mcp
|
||||
ALL_IMAGES: ${{ inputs.images }}
|
||||
# All runner instances live on the same server, so the bundle is
|
||||
# downloaded from S3 once and shared between build jobs through this
|
||||
# host-local directory. Each build job falls back to S3 if the file is
|
||||
@ -87,6 +144,9 @@ jobs:
|
||||
short_sha: ${{ steps.vars.outputs.short_sha }}
|
||||
build_key: ${{ steps.vars.outputs.build_key }}
|
||||
commit_title: ${{ steps.vars.outputs.commit_title }}
|
||||
registry: ${{ steps.vars.outputs.registry }}
|
||||
marker_key: ${{ steps.vars.outputs.marker_key }}
|
||||
images_json: ${{ steps.vars.outputs.images_json }}
|
||||
exists: ${{ steps.check.outputs.exists }}
|
||||
|
||||
steps:
|
||||
@ -101,6 +161,9 @@ jobs:
|
||||
id: vars
|
||||
env:
|
||||
GH_REF: ${{ inputs.gh_ref || github.ref_name }}
|
||||
PREVIEW: ${{ inputs.preview }}
|
||||
PREVIEW_REGISTRY: ${{ secrets.PREVIEW_REGISTRY_URL }}
|
||||
DEFAULT_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
|
||||
run: |
|
||||
# A git ref accepts characters that a Docker tag does not.
|
||||
REF_SLUG=$(printf '%s' "$GH_REF" | tr -c 'A-Za-z0-9._-' '-' | cut -c1-100)
|
||||
@ -115,6 +178,40 @@ jobs:
|
||||
echo "commit_title=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
|
||||
echo "bundle_version=$BUNDLE_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "build_key=sha-${SHORT_SHA}-${VERSION_TAG}" >> $GITHUB_OUTPUT
|
||||
# Previews need their own marker. The build key only depends on
|
||||
# the commit, so a preview that wrote the normal one would make a
|
||||
# later release build of that commit think it had nothing to do.
|
||||
if [ "$PREVIEW" = "true" ]; then
|
||||
if [ -z "$PREVIEW_REGISTRY" ]; then
|
||||
echo "::error::preview=true but PREVIEW_REGISTRY_URL is not set"
|
||||
exit 1
|
||||
fi
|
||||
REGISTRY="$PREVIEW_REGISTRY"
|
||||
MARKER_KEY="markers/images-preview-sha-${SHORT_SHA}-${VERSION_TAG}"
|
||||
else
|
||||
REGISTRY="$DEFAULT_REGISTRY"
|
||||
MARKER_KEY="markers/images-sha-${SHORT_SHA}-${VERSION_TAG}"
|
||||
fi
|
||||
echo "registry=$REGISTRY" >> $GITHUB_OUTPUT
|
||||
echo "marker_key=$MARKER_KEY" >> $GITHUB_OUTPUT
|
||||
# Validated here so that a bad value fails with a clear message
|
||||
# instead of producing an empty matrix or a Dockerfile name that
|
||||
# does not exist.
|
||||
KNOWN="backend frontend exporter storybook mcp"
|
||||
for img in $ALL_IMAGES; do
|
||||
case " $KNOWN " in
|
||||
*" $img "*) ;;
|
||||
*) echo "::error::unknown image '$img'; expected one of: $KNOWN"
|
||||
exit 1 ;;
|
||||
esac
|
||||
done
|
||||
if [ -z "$ALL_IMAGES" ]; then
|
||||
echo "::error::images is empty"
|
||||
exit 1
|
||||
fi
|
||||
# Actions expressions have no split(), so the matrix gets its JSON
|
||||
# from here and the input stays a readable space-separated list.
|
||||
echo "images_json=[$(printf '\"%s\",' $ALL_IMAGES | sed 's/,$//')]" >> $GITHUB_OUTPUT
|
||||
|
||||
# The image set is a single block, so a single set-level check is
|
||||
# enough: `promote` drops a marker object in S3 only after every
|
||||
@ -130,6 +227,7 @@ jobs:
|
||||
S3_BUCKET: ${{ secrets.S3_BUCKET }}
|
||||
FORCE: ${{ inputs.force }}
|
||||
BUILD_KEY: ${{ steps.vars.outputs.build_key }}
|
||||
MARKER_KEY: ${{ steps.vars.outputs.marker_key }}
|
||||
run: |
|
||||
if [ "$FORCE" = "true" ]; then
|
||||
echo "exists=false" >> $GITHUB_OUTPUT
|
||||
@ -148,7 +246,7 @@ jobs:
|
||||
|
||||
if aws s3api head-object \
|
||||
--bucket "$S3_BUCKET" \
|
||||
--key "markers/images-${BUILD_KEY}" \
|
||||
--key "$MARKER_KEY" \
|
||||
> /dev/null 2>&1; then
|
||||
echo "exists=true" >> $GITHUB_OUTPUT
|
||||
{
|
||||
@ -185,13 +283,18 @@ jobs:
|
||||
# never queue behind long builds.
|
||||
max-parallel: 3
|
||||
matrix:
|
||||
image: [backend, frontend, exporter, storybook, mcp]
|
||||
image: ${{ fromJSON(needs.prepare.outputs.images_json) }}
|
||||
|
||||
steps:
|
||||
- name: Set common environment variables
|
||||
# The matrix is now built from an input, so the image name reaches
|
||||
# the shell through the environment rather than being expanded into
|
||||
# the script.
|
||||
env:
|
||||
IMAGE: ${{ matrix.image }}
|
||||
run: |
|
||||
# Each job execution will use its own docker configuration.
|
||||
echo "DOCKER_CONFIG=${{ runner.temp }}/.docker-${{ github.run_id }}-${{ github.job }}-${{ matrix.image }}" >> $GITHUB_ENV
|
||||
echo "DOCKER_CONFIG=${{ runner.temp }}/.docker-${{ github.run_id }}-${{ github.job }}-${IMAGE}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
@ -202,9 +305,9 @@ jobs:
|
||||
- name: Login to Docker Registry
|
||||
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
|
||||
with:
|
||||
registry: ${{ secrets.DOCKER_REGISTRY }}
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: ${{ inputs.preview && secrets.PREVIEW_REGISTRY_URL || secrets.DOCKER_REGISTRY }}
|
||||
username: ${{ inputs.preview && secrets.PREVIEW_REGISTRY_USERNAME || secrets.DOCKER_USERNAME }}
|
||||
password: ${{ inputs.preview && secrets.PREVIEW_REGISTRY_PASSWORD || secrets.DOCKER_PASSWORD }}
|
||||
|
||||
# To avoid the "429 Too Many Requests" error when downloading
|
||||
# images from DockerHub for unregistered users.
|
||||
@ -253,10 +356,14 @@ jobs:
|
||||
mv "penpot/${IMAGE}" "bundle-${IMAGE}"
|
||||
popd
|
||||
|
||||
# Only needed to build for a foreign architecture. It registers
|
||||
# binfmt for the whole host, which the other runners on this machine
|
||||
# share, so it is skipped when nothing has to be emulated.
|
||||
- name: Set up QEMU (stable)
|
||||
if: contains(inputs.platforms, 'arm64')
|
||||
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/arm64
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
@ -274,16 +381,18 @@ jobs:
|
||||
with:
|
||||
context: ./docker/images/
|
||||
file: ./docker/images/Dockerfile.${{ matrix.image }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: ${{ inputs.platforms }}
|
||||
push: true
|
||||
provenance: mode=max
|
||||
sbom: true
|
||||
provenance: ${{ inputs.attestations && 'mode=max' || 'false' }}
|
||||
sbom: ${{ inputs.attestations }}
|
||||
# Immutable tag only; branch tags are moved atomically for the
|
||||
# whole image set by the `promote` job.
|
||||
tags: ${{ secrets.DOCKER_REGISTRY }}/${{ matrix.image }}:${{ needs.prepare.outputs.build_key }}
|
||||
tags: ${{ needs.prepare.outputs.registry }}/${{ matrix.image }}:${{ needs.prepare.outputs.build_key }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=registry,ref=${{ secrets.DOCKER_REGISTRY }}/${{ matrix.image }}:buildcache
|
||||
cache-to: type=registry,ref=${{ secrets.DOCKER_REGISTRY }}/${{ matrix.image }}:buildcache,mode=max
|
||||
# One cache per registry, so a single-arch preview build cannot
|
||||
# overwrite the cache a multi-arch release build needs.
|
||||
cache-from: type=registry,ref=${{ needs.prepare.outputs.registry }}/${{ matrix.image }}:buildcache
|
||||
cache-to: type=registry,ref=${{ needs.prepare.outputs.registry }}/${{ matrix.image }}:buildcache,mode=max
|
||||
|
||||
# ── 3a. Move the branch tags of ALL images together (fresh build) ──────
|
||||
promote:
|
||||
@ -303,13 +412,16 @@ jobs:
|
||||
- name: Login to Docker Registry
|
||||
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
|
||||
with:
|
||||
registry: ${{ secrets.DOCKER_REGISTRY }}
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: ${{ inputs.preview && secrets.PREVIEW_REGISTRY_URL || secrets.DOCKER_REGISTRY }}
|
||||
username: ${{ inputs.preview && secrets.PREVIEW_REGISTRY_USERNAME || secrets.DOCKER_USERNAME }}
|
||||
password: ${{ inputs.preview && secrets.PREVIEW_REGISTRY_PASSWORD || secrets.DOCKER_PASSWORD }}
|
||||
|
||||
# Skipped for previews: these are the tags the fixed environments
|
||||
# deploy from.
|
||||
- name: Point branch tags to the new build key
|
||||
if: inputs.move_branch_tags
|
||||
env:
|
||||
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
|
||||
DOCKER_REGISTRY: ${{ needs.prepare.outputs.registry }}
|
||||
REF_SLUG: ${{ needs.prepare.outputs.ref_slug }}
|
||||
BUILD_KEY: ${{ needs.prepare.outputs.build_key }}
|
||||
run: |
|
||||
@ -328,10 +440,10 @@ jobs:
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
|
||||
S3_BUCKET: ${{ secrets.S3_BUCKET }}
|
||||
BUILD_KEY: ${{ needs.prepare.outputs.build_key }}
|
||||
MARKER_KEY: ${{ needs.prepare.outputs.marker_key }}
|
||||
run: |
|
||||
echo "$GITHUB_RUN_ID" | aws s3 cp - \
|
||||
"s3://${S3_BUCKET}/markers/images-${BUILD_KEY}"
|
||||
"s3://${S3_BUCKET}/${MARKER_KEY}"
|
||||
|
||||
- name: Write step summary
|
||||
env:
|
||||
@ -340,15 +452,22 @@ jobs:
|
||||
BUILD_KEY: ${{ needs.prepare.outputs.build_key }}
|
||||
BUNDLE_VERSION: ${{ needs.prepare.outputs.bundle_version }}
|
||||
COMMIT_TITLE: ${{ needs.prepare.outputs.commit_title }}
|
||||
REGISTRY: ${{ needs.prepare.outputs.registry }}
|
||||
MOVE_BRANCH_TAGS: ${{ inputs.move_branch_tags }}
|
||||
run: |
|
||||
{
|
||||
echo "### ✅ Image set promoted"
|
||||
echo ""
|
||||
echo "- Version: \`${BUNDLE_VERSION}\` (\`./manage.sh version\`)"
|
||||
echo "- Commit: [\`${SHORT_SHA}\`](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${SHORT_SHA}) — ${COMMIT_TITLE}"
|
||||
echo "- Registry: \`${REGISTRY}\`"
|
||||
echo "- Built at: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
|
||||
echo ""
|
||||
echo "All \`:${REF_SLUG}\` tags now point to \`${BUILD_KEY}\`."
|
||||
if [ "$MOVE_BRANCH_TAGS" = "true" ]; then
|
||||
echo "All \`:${REF_SLUG}\` tags now point to \`${BUILD_KEY}\`."
|
||||
else
|
||||
echo "Branch tags were left untouched; deploy \`${BUILD_KEY}\`."
|
||||
fi
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
# ── 3b. Skip path: make sure THIS ref's tags point to the existing
|
||||
@ -360,7 +479,9 @@ jobs:
|
||||
runs-on: penpot-standar-runner
|
||||
timeout-minutes: 10
|
||||
needs: prepare
|
||||
if: needs.prepare.outputs.exists == 'true'
|
||||
# Nothing to ensure when the branch tags are not being moved, and running
|
||||
# it anyway would log in for nothing and claim tags were repointed.
|
||||
if: needs.prepare.outputs.exists == 'true' && inputs.move_branch_tags
|
||||
|
||||
steps:
|
||||
- name: Set common environment variables
|
||||
@ -373,13 +494,14 @@ jobs:
|
||||
- name: Login to Docker Registry
|
||||
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
|
||||
with:
|
||||
registry: ${{ secrets.DOCKER_REGISTRY }}
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
registry: ${{ inputs.preview && secrets.PREVIEW_REGISTRY_URL || secrets.DOCKER_REGISTRY }}
|
||||
username: ${{ inputs.preview && secrets.PREVIEW_REGISTRY_USERNAME || secrets.DOCKER_USERNAME }}
|
||||
password: ${{ inputs.preview && secrets.PREVIEW_REGISTRY_PASSWORD || secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Point branch tags to the existing build key
|
||||
if: inputs.move_branch_tags
|
||||
env:
|
||||
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
|
||||
DOCKER_REGISTRY: ${{ needs.prepare.outputs.registry }}
|
||||
REF_SLUG: ${{ needs.prepare.outputs.ref_slug }}
|
||||
BUILD_KEY: ${{ needs.prepare.outputs.build_key }}
|
||||
run: |
|
||||
|
||||
126
.github/workflows/build-preview.yml
vendored
Normal file
126
.github/workflows/build-preview.yml
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
name: _PREVIEW
|
||||
|
||||
run-name: >-
|
||||
_PREVIEW (${{ inputs.gh_ref }}${{ inputs.nitrate_ref != '' && format(' / admin-console:{0}', inputs.nitrate_ref) || '' }})
|
||||
|
||||
# Builds the images for a preview environment: single architecture, pushed
|
||||
# to the preview registry, leaving the branch tags alone. Only the branch is
|
||||
# asked for; everything else is set below so it cannot be got wrong.
|
||||
#
|
||||
# Use _ADHOC instead to build a branch for the fixed environments.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
gh_ref:
|
||||
description: 'Branch or ref to build'
|
||||
type: string
|
||||
required: true
|
||||
nitrate_ref:
|
||||
description: 'Branch or ref to build admin-console from, defaults to gh_ref'
|
||||
type: string
|
||||
required: false
|
||||
force:
|
||||
description: 'Rebuild even if this commit was already built'
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
workflow_call:
|
||||
inputs:
|
||||
gh_ref:
|
||||
description: 'Branch or ref to build'
|
||||
type: string
|
||||
required: true
|
||||
nitrate_ref:
|
||||
description: 'Branch or ref to build admin-console from, defaults to gh_ref'
|
||||
type: string
|
||||
required: false
|
||||
force:
|
||||
description: 'Rebuild even if this commit was already built'
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
outputs:
|
||||
build_key:
|
||||
description: 'Tag the images were published under'
|
||||
value: ${{ jobs.build-docker.outputs.build_key }}
|
||||
registry:
|
||||
description: 'Registry the images were published to'
|
||||
value: ${{ jobs.build-docker.outputs.registry }}
|
||||
admin_console_image:
|
||||
description: 'Exact reference of the admin-console image'
|
||||
value: ${{ jobs.build-docker-admin-console.outputs.image }}
|
||||
|
||||
concurrency:
|
||||
group: preview-build-${{ inputs.gh_ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
# Unchanged from any other build. The bundle is identified by commit, so a
|
||||
# branch pointing at an already built commit reuses it and compiles
|
||||
# nothing.
|
||||
build-bundle:
|
||||
permissions:
|
||||
contents: read
|
||||
uses: ./.github/workflows/build-bundle.yml
|
||||
secrets:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_REGION: ${{ secrets.AWS_REGION }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
MATTERMOST_WEBHOOK: ${{ secrets.MATTERMOST_WEBHOOK }}
|
||||
S3_BUCKET: ${{ secrets.S3_BUCKET }}
|
||||
with:
|
||||
gh_ref: ${{ inputs.gh_ref }}
|
||||
force: ${{ inputs.force }}
|
||||
|
||||
build-docker:
|
||||
needs: build-bundle
|
||||
permissions:
|
||||
contents: read
|
||||
uses: ./.github/workflows/build-docker.yml
|
||||
secrets:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_REGION: ${{ secrets.AWS_REGION }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
MATTERMOST_WEBHOOK: ${{ secrets.MATTERMOST_WEBHOOK }}
|
||||
PREVIEW_REGISTRY_PASSWORD: ${{ secrets.PREVIEW_REGISTRY_PASSWORD }}
|
||||
PREVIEW_REGISTRY_URL: ${{ secrets.PREVIEW_REGISTRY_URL }}
|
||||
PREVIEW_REGISTRY_USERNAME: ${{ secrets.PREVIEW_REGISTRY_USERNAME }}
|
||||
PUB_DOCKER_PASSWORD: ${{ secrets.PUB_DOCKER_PASSWORD }}
|
||||
PUB_DOCKER_USERNAME: ${{ secrets.PUB_DOCKER_USERNAME }}
|
||||
S3_BUCKET: ${{ secrets.S3_BUCKET }}
|
||||
with:
|
||||
gh_ref: ${{ inputs.gh_ref }}
|
||||
# Build the images from the exact commit that was bundled.
|
||||
sha: ${{ needs.build-bundle.outputs.sha }}
|
||||
force: ${{ inputs.force }}
|
||||
preview: true
|
||||
# The preview cluster is x86.
|
||||
platforms: 'linux/amd64'
|
||||
# storybook and mcp are not useful in a preview.
|
||||
images: 'backend frontend exporter'
|
||||
# Not published, so there is nothing to attest.
|
||||
attestations: false
|
||||
# The important one: moving them would change what the fixed
|
||||
# environments deploy.
|
||||
move_branch_tags: false
|
||||
|
||||
# Needs the admin-console workflow on its default branch to already accept
|
||||
# preview, platforms and attestations and to publish the reference as an
|
||||
# artifact. A dispatch with inputs the target does not declare is rejected,
|
||||
# so this fails loudly rather than quietly building the wrong thing.
|
||||
build-docker-admin-console:
|
||||
permissions: {}
|
||||
uses: ./.github/workflows/build-docker-admin-console.yml
|
||||
secrets:
|
||||
ORG_WORKFLOW_TOKEN: ${{ secrets.ORG_WORKFLOW_TOKEN }}
|
||||
with:
|
||||
gh_ref: ${{ inputs.nitrate_ref || inputs.gh_ref }}
|
||||
force: ${{ inputs.force }}
|
||||
preview: true
|
||||
platforms: 'linux/amd64'
|
||||
attestations: false
|
||||
Loading…
x
Reference in New Issue
Block a user