Repository navigation
ci: add k8s stack PR preview via labeled deploy + Cloudflare Tunnel #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 74 commits
Commits
Show all changes
115 commits
Select commit
Hold shift + click to select a range
1ef138b
ci: add k8s stack PR preview via labeled deploy + Cloudflare Tunnel
aktech 72dab46
ci: temporarily trigger smoketest on this PR for iteration
aktech 52d9f86
fix: move cloudflared --no-autoupdate flag before the run subcommand
aktech 2818f48
ci: use single-level github.fyi hostnames for the preview tunnel
aktech fedb68f
ci: drop temporary pull_request trigger from smoketest workflow
aktech b22f710
fix: fetch chart dependencies before helm install in preview workflow
aktech 1c7618a
ci: post smoketest URL as a PR comment via optional pr_number input
aktech 0a75683
fix: register the jupyterhub chart repo before dependency build
aktech 1eec127
fix: opt preview namespace into nic-operator management, add failure …
aktech 17f723b
fix: disable nebariapp for preview deploy, hub crash-loops otherwise
aktech a43dfb7
fix: set jupyterhub.custom.external-url to the tunnel hostname
aktech 57f1b00
Merge branch 'main' into add-k8s-preview-workflow
aktech a146616
ci: show deploy/expiry timestamps in preview PR comments
aktech c0ca336
Merge branch 'add-k8s-preview-workflow' of github.com:nebari-dev/neba…
aktech 65651b4
fix: make tunnel creation idempotent, retries reuse the run_id
aktech 774c0d6
Merge branch 'main' into add-k8s-preview-workflow
aktech 74d3d49
ci: source preview domain from a repo Variable instead of hardcoding it
aktech 71817f5
ci: switch preview domain to openteams.app, flatten per-PR hostname
aktech 4919f73
ci: migrate k8s-preview to action-nebari-sandbox v3 (kind, not k3d)
aktech c849c85
ci: bump kind CLI to v0.33.0 in k8s-preview for containerd config v4
aktech cec54be
ci: always dump hub logs in k8s-preview to diagnose jhub-apps startup
aktech f577f6a
ci: smoke-test jhub-apps directly in k8s-preview before opening the t…
aktech 10fa371
ci: capture hub logs after the tunnel closes, not just at startup
aktech 26f7b65
ci: cache docker build, enable Keycloak auth, always start tmate debug
aktech d15efbc
ci: wait for the operator's Keycloak secret instead of blocking helm …
aktech 2b6f1a9
ci: cover the keycloak namespace in the deploy-failure debug dump
aktech 494eee4
ci: label the preview namespace so nic-operator actually reconciles it
aktech be49af8
docs: update k8s-preview comments to match the current auth setup
aktech daba573
ci: diagnose why the operator's issuer-url secret key comes back empty
aktech 47e6606
ci: wait for issuer-url specifically, not just the secret's existence
aktech 612f07d
ci: retry the hub restart until it actually picks up the operator secret
aktech b0c12f0
ci: fix the actual bug -- hub was mounting the wrong secret name
aktech 0d041ce
ci: use --set-json for extraVolumes, not indexed --set
aktech 0b2e76e
ci: expose Keycloak's own login page through a second tunnel route
aktech f925800
ci: point Keycloak's own hostname at the public route instead of rewr…
aktech c85f9b4
ci: fix Keycloak hostname via GitOps instead of a direct kubectl patch
aktech 78b0086
ci: create a simple reviewer/admin test user in Keycloak
aktech 6c96912
ci: route hub's Keycloak backchannel calls in-cluster, not through Ac…
aktech d5c27c7
fix: point jhub-apps' hub-API client at localhost, not the hub Service
aktech fdec180
fix: the env-dict override for JUPYTERHUB_API_URL doesn't survive spawn
aktech 3ca96ef
ci: pre-fill email/name on the reviewer test user
aktech 928adec
fix: the JUPYTERHUB_API_URL rewrite for jhub-apps never actually ran
aktech ba3fd45
ci: bound the tunnel step to 20min instead of the job timeout
aktech d284543
ci: add a GitHub Deployment for the preview, not just a comment
aktech 044a28e
ci: fix the tunnel step's exit-124 handling under bash -e
aktech 7371cc1
ci: replace the preview comment's prose with a Vercel-style table
aktech f2896bc
ci: fix the deployment table's Project column
aktech 7b1df6a
ci: show a live-updating expiry time instead of a static UTC string
aktech 26bbfe1
ci: update the preview comment again when it expires
aktech f6c9f4a
ci: extend the preview's lifetime in place via an extend-preview label
aktech 6bdfafb
Merge branch 'main' into add-k8s-preview-workflow
aktech 3693d08
ci: don't let extend-preview cancel the run it's meant to extend
aktech 9ab529d
refactor: add a testable Python foundation for k8s-preview.yaml's CI …
aktech 748e6d5
refactor: move Cloudflare Tunnel/DNS logic into scripts/preview/cloud…
aktech 6844087
refactor: move Keycloak + k8s readiness logic into scripts/preview/
aktech 037c993
refactor: move remaining GitHub API/comment logic into scripts/preview/
aktech 9305abe
refactor: move the extend-preview tunnel loop into scripts/preview/tu…
aktech df6d007
ci: dump ArgoCD Application status on deploy failure
aktech 148323a
ci: also dump cloudnative-pg's own ArgoCD Application status on failure
aktech 30d7f6a
fix: update the PR comment's expiry when extend-preview actually exte…
aktech 4a3dec5
fix: the comment-timer fix computed the new expiry from the wrong clock
aktech f1809b0
ci: trim every workflow comment and cap each action at ~4 lines
aktech f492690
test: remove 4 ceremonial CLI passthrough tests
aktech 9256f2f
ci: remove the standalone tunnel smoketest workflow
aktech ed70518
ci: cut contrastive "X, not Y" padding from workflow comments
aktech 2f76800
fix: "for 20 more minutes" read as cumulative, it isn't
aktech f2661e7
build: bump actions/checkout to v7.0.1, helm/kind-action to v1.15.0
aktech 0d9d3e6
docs: trim redundant '(not cumulative)' aside in k8s-preview.yaml
aktech d3d3a2d
docs: move k8s-preview.yaml's comments into a PR Preview Environments…
aktech 7ab009d
docs: lead with a How it works diagram, drop generic debugging sectio…
aktech 23f8fa5
docs: cut implementation-detail aside from the intro paragraph
aktech 269924d
feat: point preview deploys at the PR's own JupyterLab image build
aktech e50d1d3
docs: explain why the namespace label is manual here (ArgoCD does it …
aktech 644529b
docs: frame the manual namespace label as a known gap, not a permanen…
aktech eec0b14
docs: explain why kind/kindnet can't hairpin a pod back to its own Se…
aktech 4603e0d
docs: trim the hairpin-NAT comment down, no fluff
aktech 1ef4c3f
docs: shrink the hairpin-NAT comment to a tweet, fix hub_connect_url …
aktech c751720
fix: disable prePuller.hook for preview deploys, it blocks install on…
aktech bd9dfc2
docs: state the exec-time-rewrite reason directly instead of via what…
aktech 35ab2ae
docs: attribute the jhub-apps hub-API timeout to the hub NetworkPolic…
aktech 11b307f
fix: put prePuller override at the jupyterhub level, it had swallowed…
aktech 85b2fc3
fix: label the hub pod network-access-hub so jhub-apps can reach the …
aktech 55980ee
refactor: use gh for the workflow's GitHub API steps, drop unused tun…
aktech 4044005
test: drop tests that pin request shapes and constants instead of beh…
aktech 839d712
test: drop the create-tunnel success test, it only pinned the request…
aktech 91522fd
test: remove the scripts/preview unit tests and their injection seams
aktech 7606a08
chore: drop unread tunnel_id output, gha path param, and unused PREVI…
aktech 42ad288
feat: show reviewer credentials in the PR comment and docs; tunnel.py…
aktech 8e3e646
docs: one-line why on the Keycloak hostname repoint
aktech d98ff4d
chore: drop the debug-dump script and its failure step, tmate covers it
aktech 8d17fa9
chore: drop tmate and hub log-dump steps
aktech 0c57d21
Merge branch 'main' into add-k8s-preview-workflow
aktech e1232ea
feat: keep main's pinned image as a second profile choice in previews
aktech 00f666a
feat: deploying status comment with CI run link, Keycloak admin creds…
aktech c1b6816
refactor: tunnel.py talks to the GitHub API directly, run() split int…
aktech 6e30d58
docs: deploying comment says ready in a few minutes
aktech 3487d66
feat: remove the deploy-preview label when the preview ends
aktech cbc4cfd
fix: cascade-delete the tunnel and warn instead of silently swallowin…
aktech 3c8e1bb
chore: rename the workflow to Deploy Preview
aktech 6512f5e
chore: declare pr_image.py's dependency inline (PEP 723), run it with…
aktech 101a7cb
fix: pr_image.py puts the repo root on sys.path itself, pipx run drop…
aktech bd6dcf2
docs: clarify the preview Keycloak reviewer account, drop implementat…
aktech 8a4b8df
fix: pass the Keycloak admin password via env, post a failed-preview …
aktech 5a57bb4
ci: skip preview deploys for fork PRs, drop the fork plumbing
aktech bd6e30d
docs: state the fork-PR skip with GitHub's own wording on secrets
aktech 780e76c
docs: plain wording for why fork PRs are skipped
aktech db04576
ci: keep the pinned JupyterLab image when the PR has no pr-N tag
aktech a84bfd3
ci: preview profiles sized for the 4 vCPU runner, log resource summary
aktech 699d8c7
ci: preview profile limits match their descriptions
aktech 518c347
ci: preview profile limits and guarantees in the same ballpark
aktech 9c66433
ci: let a newer preview run take over the comment and label
aktech 6b300cf
ci: preview profiles get their image selector from the single pin
aktech 081c220
ci: preview profiles get their image selector from the single pin
aktech 992d8fe
Merge branch 'main' into add-k8s-preview-workflow
aktech 6cdc581
ci: keep preview port-forwards alive, stop label events cancelling th…
aktech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,329 @@ | ||
| name: K8s Stack Preview | ||
| # See docs: docs/src/content/docs/pr-preview-workflow.md | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [labeled, unlabeled, synchronize] | ||
|
|
||
| concurrency: | ||
| group: k8s-preview-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: ${{ !(github.event.action == 'labeled' && github.event.label.name == 'extend-preview') }} | ||
|
|
||
| env: | ||
| PREVIEW_LABEL: deploy-preview | ||
| PREVIEW_DOMAIN: ${{ vars.PREVIEW_DOMAIN }} | ||
| PREVIEW_HOSTNAME: pr-${{ github.event.pull_request.number }}-data-science-pack.${{ vars.PREVIEW_DOMAIN }} | ||
| KEYCLOAK_HOSTNAME: keycloak-pr-${{ github.event.pull_request.number }}-data-science-pack.${{ vars.PREVIEW_DOMAIN }} | ||
| CLOUDFLARED_VERSION: "2026.7.3" | ||
| CLOUDFLARED_SHA256: "9d71c677db00134c1bd4144b7783486b654ad281b1ea62b4972098d19f770f17" | ||
|
|
||
| jobs: | ||
| deploy-preview: | ||
| if: >- | ||
| contains(github.event.pull_request.labels.*.name, 'deploy-preview') && | ||
| github.event.action != 'unlabeled' && | ||
| (github.event.action != 'labeled' || github.event.label.name == 'deploy-preview') | ||
| name: Deploy preview | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 90 | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
| deployments: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
|
|
||
| - name: Ensure the extend-preview label exists | ||
| run: | | ||
| python -m scripts.preview.github_api ensure-label-exists \ | ||
| --repo "${{ github.repository }}" --token "${{ secrets.GITHUB_TOKEN }}" \ | ||
| --name extend-preview --color BFD4F2 \ | ||
| --description "Push this preview's expiry back 20 minutes" | ||
|
|
||
| - name: Install kind | ||
| uses: helm/kind-action@06c1ae10762d3b9c1644e7fe69596ae519e015a2 # v1.15.0 | ||
| with: | ||
| version: v0.33.0 | ||
| install_only: true | ||
|
|
||
| - name: Provision sandbox (kind + full NIC platform stack) | ||
| id: sandbox | ||
| uses: nebari-dev/action-nebari-sandbox@9ac369ebf87ac2ae217504dcbf824c77f70e429a # v3.0.0 | ||
| with: | ||
| cluster-name: pr-preview-${{ github.event.pull_request.number }} | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 | ||
|
|
||
| - name: Build hub image from this PR | ||
| uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 | ||
| with: | ||
| context: images/ | ||
| target: jupyterhub | ||
| tags: nebari-data-science-pack-jupyterhub:preview | ||
| load: true | ||
| cache-from: type=gha,scope=k8s-preview-jupyterhub | ||
| cache-to: type=gha,scope=k8s-preview-jupyterhub,mode=max | ||
|
|
||
| - name: Side-load hub image into the sandbox cluster | ||
| run: kind load docker-image nebari-data-science-pack-jupyterhub:preview --name ${{ steps.sandbox.outputs.cluster-name }} | ||
|
|
||
| - name: Fetch chart dependencies | ||
| run: | | ||
| helm repo add jupyterhub https://hub.jupyter.org/helm-chart/ | ||
| helm dependency build . | ||
|
|
||
| - name: Create + label the preview namespace for the operator | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: | | ||
| kubectl create namespace pr-preview --dry-run=client -o yaml | kubectl apply -f - | ||
| kubectl label namespace pr-preview nebari.dev/managed=true --overwrite | ||
|
|
||
| - name: Point Keycloak's own hostname at the public tunnel route | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: | | ||
| python -m scripts.preview.keycloak_gitops patch \ | ||
| --gitops-dir "$HOME/.nic/gitops/${{ steps.sandbox.outputs.cluster-name }}" \ | ||
| --kc-public-url "https://$KEYCLOAK_HOSTNAME" | ||
|
|
||
| - name: Point the preview at this PR's own JupyterLab image build | ||
| if: github.event.pull_request.head.repo.fork == false | ||
| run: | | ||
| pip install --no-cache-dir "ruamel.yaml==0.19.1" | ||
| python -m scripts.preview.pr_image set-tag --tag "pr-${{ github.event.pull_request.number }}" | ||
|
|
||
| - name: Deploy chart | ||
| id: deploy | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: | | ||
| helm upgrade --install preview . -f values.preview.yaml \ | ||
| --namespace pr-preview --create-namespace \ | ||
| --set nebariapp.hostname="$PREVIEW_HOSTNAME" --set jupyterhub.custom.external-url="$PREVIEW_HOSTNAME" | ||
|
|
||
| - name: Wait for operator to provision the Keycloak client secret | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: | | ||
| python -m scripts.preview.k8s_wait wait-for-secret-key \ | ||
| --namespace pr-preview --secret preview-nebari-data-science-pack-oidc-client \ | ||
| --key issuer-url --timeout-s 180 --poll-interval-s 5 | ||
|
|
||
| - name: Restart hub until it picks up the operator secret | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: | | ||
| python -m scripts.preview.k8s_wait restart-until-ready \ | ||
| --namespace pr-preview --deployment hub --rollout-timeout-s 90 --max-attempts 5 | ||
|
|
||
| - name: Wait for proxy | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: kubectl -n pr-preview rollout status deployment/proxy --timeout=180s | ||
|
|
||
| - name: Port-forward JupyterHub proxy | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: | | ||
| kubectl -n pr-preview port-forward svc/proxy-public 8000:80 \ | ||
| > /tmp/port-forward.log 2>&1 & | ||
| echo "PORT_FORWARD_PID=$!" >> "$GITHUB_ENV" | ||
| sleep 3 | ||
|
|
||
| - name: Port-forward Keycloak | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: | | ||
| kubectl -n keycloak port-forward svc/keycloak-keycloakx-http 8001:8080 \ | ||
| > /tmp/port-forward-keycloak.log 2>&1 & | ||
| echo "KEYCLOAK_PORT_FORWARD_PID=$!" >> "$GITHUB_ENV" | ||
| sleep 3 | ||
|
|
||
| - name: Create a test login user in Keycloak | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: | | ||
| admin_password=$(kubectl -n keycloak get secret keycloak-admin-credentials -o jsonpath='{.data.admin-password}' | base64 -d) | ||
| python -m scripts.preview.keycloak create-reviewer-user \ | ||
| --base-url "http://localhost:8001" --realm nebari --admin-password "$admin_password" | ||
|
|
||
| - name: Smoke-test jhub-apps service | ||
| if: always() | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: | | ||
| curl -sS -o /tmp/japps-root.html -w 'japps HTTP %{http_code}\n' http://localhost:8000/services/japps/ || true; head -c 2000 /tmp/japps-root.html || true | ||
| kubectl -n pr-preview exec deploy/hub -- ps aux | grep -i "uvicorn\|japps" || true | ||
|
|
||
| - name: Dump hub logs (jhub-apps startup) | ||
| if: always() | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: kubectl -n pr-preview logs deployment/hub --tail=500 | ||
|
|
||
| - name: Debug pod/job status on deploy failure | ||
| if: failure() | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: bash scripts/preview-debug-dump.sh | ||
|
|
||
| - name: Debug via tmate SSH on deploy failure | ||
| if: failure() | ||
| uses: mxschmitt/action-tmate@35b54afac29c97fb54faba5b513f8fbd1882f113 # v3.24 | ||
| timeout-minutes: 20 | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| with: | ||
| limit-access-to-actor: true | ||
|
|
||
| - name: Install cloudflared | ||
| run: | | ||
| curl -fsSL -o /tmp/cloudflared \ | ||
| "https://github.com/cloudflare/cloudflared/releases/download/${CLOUDFLARED_VERSION}/cloudflared-linux-amd64" | ||
| echo "${CLOUDFLARED_SHA256} /tmp/cloudflared" | sha256sum -c - | ||
| chmod +x /tmp/cloudflared | ||
|
|
||
| - name: Create Cloudflare Tunnel for this PR | ||
| id: cf_tunnel | ||
| env: | ||
| CF_API_TOKEN: ${{ secrets.CLOUDFLARE_TUNNEL_API_TOKEN }} | ||
| CF_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TUNNEL_ACCOUNT_ID }} | ||
| run: | | ||
| python -m scripts.preview.cloudflare create-tunnel \ | ||
| --account-id "$CF_ACCOUNT_ID" --api-token "$CF_API_TOKEN" --name "pr-${{ github.event.pull_request.number }}-${{ github.run_id }}" \ | ||
| --preview-hostname "$PREVIEW_HOSTNAME" --preview-service "http://localhost:8000" \ | ||
| --keycloak-hostname "$KEYCLOAK_HOSTNAME" --keycloak-service "http://localhost:8001" | ||
|
|
||
| - name: Point DNS at the tunnel | ||
| id: cf_dns | ||
| env: | ||
| CF_API_TOKEN: ${{ secrets.CLOUDFLARE_TUNNEL_API_TOKEN }} | ||
| run: | | ||
| python -m scripts.preview.cloudflare create-dns \ | ||
| --api-token "$CF_API_TOKEN" --domain "$PREVIEW_DOMAIN" --target "${TUNNEL_ID}.cfargotunnel.com" \ | ||
| --preview-hostname "$PREVIEW_HOSTNAME" --keycloak-hostname "$KEYCLOAK_HOSTNAME" | ||
|
|
||
| - name: Compute deployment timestamps | ||
| id: timestamps | ||
| run: | | ||
| echo "deployed_at=$(date -u +'%Y-%m-%d %H:%M UTC')" >> "$GITHUB_OUTPUT" | ||
| echo "expires_at=$(date -u -d '+20 minutes' +'%Y-%m-%d %H:%M UTC')" >> "$GITHUB_OUTPUT" | ||
| echo "deployed_at_iso=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT" | ||
| echo "expires_at_iso=$(date -u -d '+20 minutes' +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create GitHub deployment | ||
| run: | | ||
| python -m scripts.preview.github_api create-and-activate \ | ||
| --repo "${{ github.repository }}" --token "${{ secrets.GITHUB_TOKEN }}" --ref "${{ github.event.pull_request.head.sha }}" \ | ||
| --environment "pr-${{ github.event.pull_request.number }}-preview" --task "deploy:preview" --description "K8s stack preview" \ | ||
| --environment-url "${{ steps.cf_dns.outputs.url }}" --status-description "Live for 20 minutes" --log-url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
|
|
||
| - name: Render the ready-preview comment body | ||
| id: render_ready | ||
| run: | | ||
| python -m scripts.preview.comment render-ready ${{ github.event.pull_request.head.repo.fork && '--fork' || '' }} \ | ||
| --url "${{ steps.cf_dns.outputs.url }}" --keycloak-url "${{ steps.cf_dns.outputs.keycloak_url }}" \ | ||
| --deployed-at "${{ steps.timestamps.outputs.deployed_at }}" --deployed-at-iso "${{ steps.timestamps.outputs.deployed_at_iso }}" \ | ||
| --expires-at "${{ steps.timestamps.outputs.expires_at }}" --expires-at-iso "${{ steps.timestamps.outputs.expires_at_iso }}" | ||
|
|
||
| - name: Comment preview link on PR | ||
| id: comment_preview | ||
| uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 | ||
| with: | ||
| header: k8s-preview | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| message: ${{ steps.render_ready.outputs.body }} | ||
|
|
||
| - name: Run tunnel until it times out (extend via the extend-preview label) | ||
| run: | | ||
| python -m scripts.preview.tunnel run ${{ github.event.pull_request.head.repo.fork && '--fork' || '' }} \ | ||
| --cloudflared /tmp/cloudflared --token "${TUNNEL_TOKEN}" --repo "${{ github.repository }}" --pr "${{ github.event.pull_request.number }}" --github-token "${{ secrets.GITHUB_TOKEN }}" \ | ||
| --url "${{ steps.cf_dns.outputs.url }}" --keycloak-url "${{ steps.cf_dns.outputs.keycloak_url }}" \ | ||
| --deployed-at "${{ steps.timestamps.outputs.deployed_at }}" --deployed-at-iso "${{ steps.timestamps.outputs.deployed_at_iso }}" | ||
|
|
||
| - name: Dump hub logs after tunnel closes | ||
| if: always() | ||
| env: | ||
| KUBECONFIG: ${{ steps.sandbox.outputs.kubeconfig }} | ||
| run: kubectl -n pr-preview logs deployment/hub --tail=1000 || true | ||
|
|
||
| - name: Mark GitHub deployment inactive | ||
| if: always() | ||
| run: | | ||
| python -m scripts.preview.github_api mark-inactive \ | ||
| --repo "${{ github.repository }}" --token "${{ secrets.GITHUB_TOKEN }}" \ | ||
| --deployment-id "${DEPLOYMENT_ID:-}" --description "Preview expired" | ||
|
|
||
| - name: Render the expired-preview comment body | ||
| id: render_expired | ||
| if: always() && steps.comment_preview.outcome == 'success' | ||
| run: | | ||
| python -m scripts.preview.comment render-expired \ | ||
| --expires-at "${{ steps.timestamps.outputs.expires_at }}" \ | ||
| --expires-at-iso "${{ steps.timestamps.outputs.expires_at_iso }}" | ||
|
|
||
| - name: Comment that the preview expired | ||
| if: always() && steps.comment_preview.outcome == 'success' | ||
| uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 | ||
| with: | ||
| header: k8s-preview | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| message: ${{ steps.render_expired.outputs.body }} | ||
|
|
||
| - name: Delete DNS record | ||
| if: always() | ||
| env: | ||
| CF_API_TOKEN: ${{ secrets.CLOUDFLARE_TUNNEL_API_TOKEN }} | ||
| run: | | ||
| python -m scripts.preview.cloudflare delete-dns \ | ||
| --api-token "$CF_API_TOKEN" --zone-id "${ZONE_ID:-}" \ | ||
| --record-id "${DNS_RECORD_ID:-}" --record-id "${KEYCLOAK_DNS_RECORD_ID:-}" | ||
|
|
||
| - name: Delete Cloudflare Tunnel | ||
| if: always() | ||
| env: | ||
| CF_API_TOKEN: ${{ secrets.CLOUDFLARE_TUNNEL_API_TOKEN }} | ||
| CF_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TUNNEL_ACCOUNT_ID }} | ||
| run: | | ||
| python -m scripts.preview.cloudflare delete-tunnel \ | ||
| --account-id "$CF_ACCOUNT_ID" --api-token "$CF_API_TOKEN" --tunnel-id "${TUNNEL_ID:-}" | ||
|
|
||
| cleanup-preview: | ||
| if: github.event.action == 'unlabeled' && github.event.label.name == 'deploy-preview' | ||
| name: Stop preview | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| actions: write | ||
| deployments: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
|
|
||
| - name: Cancel the in-flight preview run for this PR | ||
| run: | | ||
| python -m scripts.preview.github_api cancel-in-flight-run \ | ||
| --repo "${{ github.repository }}" --token "${{ secrets.GITHUB_TOKEN }}" \ | ||
| --workflow-name "K8s Stack Preview" --pr "${{ github.event.pull_request.number }}" | ||
|
|
||
| - name: Mark GitHub deployment inactive | ||
| run: | | ||
| python -m scripts.preview.github_api mark-latest-inactive \ | ||
| --repo "${{ github.repository }}" --token "${{ secrets.GITHUB_TOKEN }}" \ | ||
| --environment "pr-${{ github.event.pull_request.number }}-preview" \ | ||
| --description "Preview stopped (label removed)" | ||
|
|
||
| - name: Render the stopped-preview comment body | ||
| id: render_stopped | ||
| run: python -m scripts.preview.comment render-stopped | ||
|
|
||
| - name: Comment that the preview stopped | ||
| uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 | ||
| with: | ||
| header: k8s-preview | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| message: ${{ steps.render_stopped.outputs.body }} |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.