okteto-preview
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOkteto Preview Environments Skill
Okteto 预览环境技能
A Preview Environment is a live, production-like instance of the application deployed from a git branch, usually tied to the lifecycle of a pull request. Okteto deploys it into a dedicated namespace named after the preview and gives you shareable URLs, so reviewers, PMs, and stakeholders can click through real functionality without any local setup.
This skill covers two jobs that meet in one ownership model: driving previews directly with the CLI (deploy a branch, hand back the URL) and authoring the CI automation that owns previews per-PR. Before touching a preview, know which of the two owns it — that decides who redeploys it, who posts its URL, and who tears it down.
预览环境是从Git分支部署的、与生产环境类似的实时应用实例,通常与拉取请求(PR)的生命周期绑定。Okteto会将其部署到以预览环境名称命名的专属命名空间中,并提供可共享的URL,这样评审人员、产品经理和利益相关者无需任何本地配置,即可直接体验真实功能。
本技能涵盖两种场景下的操作:通过CLI直接驱动预览环境(部署分支、返回访问URL),以及编写CI自动化流程来管理每个PR的预览环境。操作预览环境前,需明确其归属方——这将决定谁有权重新部署、发布URL以及销毁该环境。
Operating rules
操作规则
- Previews deploy from the pushed branch, not your working tree. clones the repository at
okteto preview deployand deploys that. Local uncommitted changes never reach a preview. Committing and pushing the developer's work is their call — in collaborative mode, show what's uncommitted and confirm before committing or pushing anything on their behalf. In autonomous mode, push the task branch you own before deploying.--branch - Always name the preview explicitly (e.g. ), and make it a valid name (see Naming previews). Redeploying with the same name updates the same preview; omitting the name generates a random one that CI and cleanup jobs can never find again.
pr-1234 - Use a preview to share, a namespace to work. Iterating on code belongs in a dev environment (skill). A preview is the artifact you hand to reviewers — it has no file sync and no dev containers of yours attached.
okteto - Never destroy a preview you did not create. Same doctrine as the skill's cleanup rules: a preview you created for your own task is yours to destroy; shared/global previews and CI-owned previews are not (see Cleanup and teardown).
okteto - In CI, the pipeline owns the lifecycle. Deploy on PR open/update, destroy on PR close — via and
okteto/deploy-preview(GitHub) orokteto/destroy-preview/okteto preview deployjobs (GitLab).destroy
- 预览环境从已推送的分支部署,而非本地工作目录。会克隆
okteto preview deploy指定的分支并进行部署。本地未提交的更改永远不会同步到预览环境。是否提交并推送代码由开发者决定——在协作模式下,需先展示未提交的更改,再确认是否代表用户提交或推送;在自主模式下,需先推送自己负责的任务分支,再进行部署。--branch - 始终显式命名预览环境(例如),且名称需符合规范(详见预览环境命名规则)。使用相同名称重新部署会更新现有预览环境;若省略名称,系统会生成随机名称,导致CI和清理任务无法找到该环境。
pr-1234 - 预览环境用于共享,命名空间用于开发。代码迭代应在开发环境(技能)中进行。预览环境是交付给评审人员的产物——它不支持文件同步,也不会附加你的开发容器。
okteto - 切勿销毁非你创建的预览环境。与技能的清理规则一致:你为自身任务创建的预览环境可自行销毁;共享/全局预览环境以及CI托管的预览环境则不可(详见清理与销毁)。
okteto - CI流程掌控生命周期。在PR开启/更新时部署,在PR关闭时销毁——通过GitHub的和
okteto/deploy-previewAction,或GitLab的okteto/destroy-preview/okteto preview deploy任务实现。destroy
Preview vs. namespace: which environment does this task need?
预览环境 vs 命名空间:任务需要哪种环境?
Both give you an isolated, deployed copy of the application. They answer different questions:
| Dev environment (namespace) | Preview Environment | |
|---|---|---|
| Deploys from | Your local working tree ( | A pushed git branch (server-side clone) |
| Lifecycle | Yours — lives as long as the work does | A pull request — created on open, destroyed on close |
| Audience | You / the agent doing the work | Reviewers, PMs, stakeholders, the PR thread |
File sync / | Yes — iterate live | No — redeploy by pushing to the branch |
| Where it shows up | Namespaces in the Okteto dashboard | Previews section of the dashboard, with repo/branch/PR links |
| Created by | | |
Decision guide:
- "Fix this, test this, debug this" → dev environment in a namespace. Follow the skill.
okteto - "Give me / the team a link to see branch X or PR Y" → preview environment.
- Ticket-to-PR flows use both: do the work in a namespace dev environment, push the branch, open the PR — then deploy a preview from the pushed branch and post its URL on the PR. The namespace is your workbench; the preview is the deliverable reviewers click.
两者都能提供独立的应用部署实例,但适用场景不同:
| 开发环境(命名空间) | 预览环境 | |
|---|---|---|
| 部署来源 | 本地工作目录( | 已推送的Git分支(服务器端克隆) |
| 生命周期 | 由你掌控——与工作周期一致 | 与拉取请求绑定——创建于PR开启时,销毁于PR关闭时 |
| 受众 | 你/执行任务的Agent | 评审人员、产品经理、利益相关者、PR讨论线程参与者 |
文件同步 / | 支持——可实时迭代 | 不支持——需推送分支重新部署 |
| 展示位置 | Okteto控制台的命名空间列表 | 控制台的预览环境板块,包含仓库/分支/PR链接 |
| 创建方式 | | |
决策指南:
- “修复、测试、调试代码” → 使用命名空间中的开发环境,遵循技能规则。
okteto - “给我/团队一个分支X或PR Y的访问链接” → 使用预览环境。
- “工单转PR”流程需结合两者:在命名空间开发环境中完成工作,推送分支后开启PR——然后从已推送的分支部署预览环境,并将URL发布到PR中。命名空间是你的工作台,预览环境是评审人员可点击访问的交付物。
Deploying a preview
部署预览环境
Previews deploy the code Okteto clones from the repository — so push first:
bash
git push -u origin <branch>
okteto preview deploy pr-1234 --branch <branch> --waitKey flags (see the quick reference for the full list):
- — defaults to
--scope personal|global: accessible to all members of the organization. Useglobalfor experiments only you (and people you explicitly share with) should see. Don't assume personal is the default — it isn't. Sharing a personal preview with specific people happens on its dashboard page (personal), not through the CLI, and only the owner or an admin can share it./previews/<name> - — defaults to the current branch of the checkout you run from.
--branch <branch> - — defaults to the current repo's remote URL. Pass it explicitly when deploying a repo you don't have checked out.
--repository <url> - — injects a variable into the manifest's deploy commands. Repeat the flag for multiple variables.
--var KEY=VALUE - — the HTTPS URL of the pull/merge request; links the PR in the dashboard's Previews list.
--sourceUrl <pr-url> - — defaults to
--timeout. Raise it for large stacks (5m0s).-t 15m - — path to the Okteto Manifest if it isn't at the default location.
--file
预览环境部署的是Okteto从仓库克隆的代码——因此需先推送代码:
bash
git push -u origin <branch>
okteto preview deploy pr-1234 --branch <branch> --wait关键参数(完整列表详见CLI速查):
- — 默认值为**
--scope personal|global**:组织内所有成员均可访问。使用global仅用于你(及你明确共享的人员)可见的实验。注意默认值并非personal。共享个人预览环境需在控制台页面(personal)操作,仅所有者或管理员有权限。/previews/<name> - — 默认值为当前本地检出的分支。
--branch <branch> - — 默认值为当前仓库的远程URL。当部署未检出的仓库时需显式指定。
--repository <url> - — 向清单的部署命令中注入变量,可重复使用该参数添加多个变量。
--var KEY=VALUE - — 拉取/合并请求的HTTPS URL;用于在控制台预览列表中关联PR。
--sourceUrl <pr-url> - — 默认值为
--timeout。大型堆栈可延长超时时间(例如5m0s)。-t 15m - — Okteto清单的路径,若不在默认位置需指定。
--file
Naming previews
预览环境命名规则
The preview name becomes the namespace name, so it must be a valid RFC 1123 DNS label: at most 63 characters; lowercase letters, digits, and only; starting and ending with a letter or digit (regex ). No uppercase, dots, or underscores, and avoid the reserved prefix. Derive a safe slug from a branch the same way the skill derives namespace names:
-^[a-z0-9]([-a-z0-9]*[a-z0-9])?$kube-oktetobash
slug=$(git branch --show-current | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g; s/^-*//; s/-*$//' | cut -c1-50)Conventions:
- PR-keyed (GitHub): — stable across pushes to the PR, easy for the cleanup job to find.
pr-<number> - Branch-keyed (GitLab): — e.g.
review-<branch-slug>, one preview per branch.review-$CI_COMMIT_REF_SLUG
Getting the PR number: in CI it's in the event (); on a checked-out branch, . If the PR doesn't exist yet, don't invent a number — use a branch-keyed name, or open the PR first and deploy the preview after.
${{ github.event.number }}gh pr view --json number --jq .numberIf you omit the name, the CLI generates a random one. Fine for a quick manual experiment; wrong everywhere else — a redeploy creates a second preview instead of updating the first.
预览环境名称会成为命名空间名称,因此必须符合RFC 1123 DNS标签规范:最多63个字符;仅包含小写字母、数字和;必须以字母或数字开头和结尾(正则表达式)。不允许大写字母、点或下划线,避免使用保留前缀。可通过以下命令从分支生成安全的名称,与技能生成命名空间名称的方式一致:
-^[a-z0-9]([-a-z0-9]*[a-z0-9])?$kube-oktetobash
slug=$(git branch --show-current | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g; s/^-*//; s/-*$//' | cut -c1-50)命名约定:
- PR关联式(GitHub):——在PR推送过程中保持稳定,便于清理任务查找。
pr-<编号> - 分支关联式(GitLab):——例如
review-<分支缩写>,每个分支对应一个预览环境。review-$CI_COMMIT_REF_SLUG
获取PR编号:在CI中可从事件变量获取();在已检出的分支上,可使用。若PR尚未创建,请勿自行生成编号——使用分支关联式名称,或先创建PR再部署预览环境。
${{ github.event.number }}gh pr view --json number --jq .number若省略名称,CLI会生成随机名称。适用于快速手动实验,但不适用于其他场景——重新部署会创建第二个预览环境,而非更新现有环境。
Capturing endpoints and posting the URL back
获取端点并发布URL
After a successful deploy, capture the endpoints:
bash
okteto preview endpoints pr-1234 # JSON (default) — parse programmatically
okteto preview endpoints pr-1234 -o md # Markdown — made for pasting into a PR commentThe dashboard page for a preview lives at .
https://<your-okteto-url>/previews/<name>Posting to the PR with (when you deployed the preview yourself, outside CI):
ghbash
gh pr comment 1234 --body "$(cat <<EOF
Preview environment ready — [dashboard](https://<your-okteto-url>/previews/pr-1234)
$(okteto preview endpoints pr-1234 -o md)
EOF
)"Posting to a thread (Slack, ticket, chat): same content — the endpoints from plus the dashboard link. The whole point of a preview is that anyone in the thread can click the same URL.
-o mdIn CI you usually don't need to post at all: the GitHub Action posts the URL and endpoints as a PR comment automatically when the env var is set. Don't add a second step on top of it.
okteto/deploy-previewGITHUB_TOKENgh pr comment部署成功后,可获取端点信息:
bash
okteto preview endpoints pr-1234 # 默认返回JSON——便于程序解析
okteto preview endpoints pr-1234 -o md # 返回Markdown格式——适合粘贴到PR评论中预览环境的控制台页面地址为。
https://<你的Okteto地址>/previews/<名称>使用发布到PR(当你在CI外自行部署预览环境时):
ghbash
gh pr comment 1234 --body "$(cat <<EOF
预览环境已就绪 — [控制台](https://<你的Okteto地址>/previews/pr-1234)
$(okteto preview endpoints pr-1234 -o md)
EOF
)"发布到讨论线程(Slack、工单、聊天工具):内容相同——包含返回的端点信息和控制台链接。预览环境的核心价值在于线程中的任何人都可点击同一URL访问。
-o md在CI中通常无需手动发布:当设置环境变量后, GitHub Action会自动将URL和端点信息作为PR评论发布。无需额外添加步骤。
GITHUB_TOKENokteto/deploy-previewgh pr commentPreviews in CI
CI中的预览环境配置
GitHub Actions: okteto/deploy-preview
okteto/deploy-previewGitHub Actions:okteto/deploy-preview
okteto/deploy-previewThe canonical pair of workflows — deploy on PR open/update, destroy on close:
yaml
undefined标准工作流组合——PR开启/更新时部署,PR关闭时销毁:
yaml
undefined.github/workflows/preview.yaml
.github/workflows/preview.yaml
on:
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false # never true — cancelling an in-progress deploy leaves the preview inconsistent
jobs:
preview:
runs-on: ubuntu-latest
steps:
- name: Context
uses: okteto/context@latest
with:
url: ${{ secrets.OKTETO_CONTEXT }}
token: ${{ secrets.OKTETO_TOKEN }}
- name: Deploy preview environment
uses: okteto/deploy-preview@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # enables the automatic PR comment with the URL
with:
name: pr-${{ github.event.number }}
timeout: 15m
```yamlon:
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false # 切勿设为true——取消正在进行的部署会导致预览环境不一致
jobs:
preview:
runs-on: ubuntu-latest
steps:
- name: 配置上下文
uses: okteto/context@latest
with:
url: ${{ secrets.OKTETO_CONTEXT }}
token: ${{ secrets.OKTETO_TOKEN }}
- name: 部署预览环境
uses: okteto/deploy-preview@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 启用自动发布URL到PR评论的功能
with:
name: pr-${{ github.event.number }}
timeout: 15m
```yaml.github/workflows/preview-closed.yaml
.github/workflows/preview-closed.yaml
on:
pull_request:
types:
- closed
jobs:
closed:
runs-on: ubuntu-latest
steps:
- name: Context
uses: okteto/context@latest
with:
url: ${{ secrets.OKTETO_CONTEXT }}
token: ${{ secrets.OKTETO_TOKEN }}
- name: Destroy preview environment
uses: okteto/destroy-preview@latest
with:
name: pr-${{ github.event.number }} # must match the deploy workflow's name exactly
Repository secrets required: `OKTETO_CONTEXT` (the URL of the Okteto instance, e.g. `https://okteto.example.com`) and `OKTETO_TOKEN` (an Okteto Admin Access Token). `GITHUB_TOKEN` is populated by GitHub automatically.
`okteto/deploy-preview` inputs: `name` (required), `scope` (default `global`), `variables` (comma-separated `VAR1=VAL1,VAR2=VAL2`), `file`, `branch` (defaults to the branch that triggered the action), `timeout`, `log-level`, `dependencies`, `labels` (comma-separated).on:
pull_request:
types:
- closed
jobs:
closed:
runs-on: ubuntu-latest
steps:
- name: 配置上下文
uses: okteto/context@latest
with:
url: ${{ secrets.OKTETO_CONTEXT }}
token: ${{ secrets.OKTETO_TOKEN }}
- name: 销毁预览环境
uses: okteto/destroy-preview@latest
with:
name: pr-${{ github.event.number }} # 必须与部署工作流中的名称完全一致
所需仓库密钥:`OKTETO_CONTEXT`(Okteto实例的URL,例如`https://okteto.example.com`)和`OKTETO_TOKEN`(Okteto管理员访问令牌)。`GITHUB_TOKEN`由GitHub自动填充。
`okteto/deploy-preview`输入参数:`name`(必填)、`scope`(默认`global`)、`variables`(逗号分隔的`VAR1=VAL1,VAR2=VAL2`)、`file`、`branch`(默认触发Action的分支)、`timeout`、`log-level`、`dependencies`、`labels`(逗号分隔)。GitLab CI/CD
GitLab CI/CD
Same shape with the CLI directly (image ): a job runs , and a job runs when the branch is deleted or the MR merges. Pass the preview URL via the job's so reviewers can open it from GitLab.
ghcr.io/okteto/okteto:latestreviewokteto preview deploy review-$CI_COMMIT_REF_SLUG --branch $CI_COMMIT_REF_NAME --repository $CI_PROJECT_URLstop-reviewokteto preview destroy review-$CI_COMMIT_REF_SLUGenvironment.url使用CLI直接配置(镜像为):任务执行,任务在分支删除或MR合并时执行。通过任务的传递预览URL,便于评审人员从GitLab直接访问。
ghcr.io/okteto/okteto:latestreviewokteto preview deploy review-$CI_COMMIT_REF_SLUG --branch $CI_COMMIT_REF_NAME --repository $CI_PROJECT_URLstop-reviewokteto preview destroy review-$CI_COMMIT_REF_SLUGenvironment.urlInspecting, sleeping, and waking previews
查看、休眠与唤醒预览环境
bash
okteto preview list # status and scope of your previews (-o json|yaml)
okteto preview list --label team-a # filter by label
okteto preview sleep pr-1234 # scale it down to save resources (owner or admin only)
okteto preview wake pr-1234 # bring a sleeping preview backSleeping keeps the preview and its configuration; waking restores it. Prefer over when the goal is saving resources on a preview someone may still need. Admins can also mark a preview Persistent in the dashboard, which exempts it from automatic sleep and garbage collection — that's a dashboard action, not a CLI one.
sleepdestroyApplications can detect they're running in a preview via the environment variable — useful when the task is "make the app behave differently in previews".
OKTETO_IS_PREVIEW_ENVIRONMENT=truebash
okteto preview list # 查看预览环境的状态和范围(支持`-o json|yaml`格式)
okteto preview list --label team-a # 按标签过滤预览环境
okteto preview sleep pr-1234 # 缩容以节省资源(仅所有者或管理员可操作)
okteto preview wake pr-1234 # 唤醒休眠的预览环境休眠会保留预览环境及其配置;唤醒会恢复其运行状态。当需要为仍可能被使用的预览环境节省资源时,优先选择而非。管理员还可在控制台中将预览环境标记为持久化,使其免于自动休眠和垃圾回收——此操作仅能在控制台完成,无法通过CLI执行。
sleepdestroy应用可通过环境变量检测自身是否运行在预览环境中——适用于“让应用在预览环境中表现不同”的场景。
OKTETO_IS_PREVIEW_ENVIRONMENT=trueCleanup and teardown
清理与销毁
okteto preview destroy <name>destroyoktetoDecide who owns teardown when you create the preview. If the repo has preview workflows, prefer opening the PR and letting CI own the whole lifecycle, teardown included. If you deploy ad hoc for a PR, teardown rides on the PR: destroy the preview yourself when the PR closes if you're still running; otherwise say so where you posted the URL — "this preview is not destroyed automatically; after the PR closes, run ". Sleep and the platform's garbage collection are a resource backstop, not an owner.
okteto preview destroy <name>| Situation | May the agent destroy it? |
|---|---|
| Preview the agent created this session for its own task | Yes — yours to tear down when the work is done and the URL is no longer needed |
CI-owned preview (e.g. | No — the close-PR workflow owns teardown. Destroying it mid-review breaks the link reviewers are using |
| Global preview created by someone else | Never without explicit instruction |
| Someone else's personal preview | Never — and only admins or the owner could anyway |
- In collaborative mode, surface the command and let the developer run it: "To tear down the preview, run: ".
okteto preview destroy pr-1234 - In autonomous mode, a preview you created this session is yours to destroy once the task no longer needs it — the same "you created it, you own its teardown" rule as the skill's worktree namespaces. One caveat: if you posted its URL to a PR or thread, reviewers may still be using it — leave it running (or
okteto) and report the teardown command instead. For any preview you did not create, destroy only with explicit authorization, a documented cleanup policy, or pipeline ownership of this run.okteto preview sleep <name> - Don't use as a retry. A failed or stale preview is fixed by redeploying with the same name —
destroyupdates in place.okteto preview deploy <name>
okteto preview destroy <name>destroyokteto创建预览环境时需明确销毁权限归属。若仓库已有预览工作流,优先选择开启PR并让CI掌控整个生命周期(包括销毁)。若你为PR临时部署预览环境,销毁操作需与PR绑定:PR关闭时若你仍在维护,可自行销毁;否则需在发布URL的位置说明“此预览环境不会自动销毁;PR关闭后,执行即可销毁”。休眠和平台的垃圾回收只是资源保障措施,而非替代所有者的职责。
okteto preview destroy <name>| 场景 | Agent是否可销毁? |
|---|---|
| Agent在本次会话中为自身任务创建的预览环境 | 是——工作完成且URL不再需要时可销毁 |
CI托管的预览环境(例如工作流管理的 | 否——PR关闭工作流负责销毁。评审期间销毁会破坏评审人员正在使用的链接 |
| 他人创建的全局预览环境 | 绝对不可——除非有明确指令 |
| 他人的个人预览环境 | 绝对不可——仅管理员或所有者可操作 |
- 在协作模式下,展示销毁命令并让开发者自行执行:“如需销毁预览环境,请执行:”。
okteto preview destroy pr-1234 - 在自主模式下,你本次会话创建的预览环境可在任务不再需要时销毁——遵循“谁创建谁负责销毁”的规则,与技能中工作目录命名空间的规则一致。注意:若你已将URL发布到PR或讨论线程,评审人员可能仍在使用——可选择保持运行(或执行
okteto),并告知销毁命令。对于非你创建的预览环境,仅在有明确授权、文档化清理策略或本次流程由管道掌控时才可销毁。okteto preview sleep <name> - 切勿用作为重试手段。失败或过期的预览环境可通过使用相同名称重新部署来修复——
destroy会就地更新。okteto preview deploy <name>
CLI quick reference
CLI速查
| Command | Collaborative | Autonomous | Purpose |
|---|---|---|---|
| Agent | Agent | Deploy a preview from a pushed branch |
| Agent | Agent | List preview URLs ( |
| Agent | Agent | Status and scope of your previews |
| Agent (own) | Agent (own) | Scale down a preview you own |
| Agent | Agent | Wake a sleeping preview |
| User (or self-created) | Self-created / with policy | Tear down a preview and its namespace |
okteto preview deploy-b/--branch--repository-s/--scope personal|globalglobal-v/--var KEY=VALUE--sourceUrl <pr-url>-t/--timeout5m0s-w/--waittrue-f/--file--label--dependencies| 命令 | 协作模式 | 自主模式 | 用途 |
|---|---|---|---|
| Agent执行 | Agent执行 | 从已推送的分支部署预览环境 |
| Agent执行 | Agent执行 | 列出预览环境URL(默认返回JSON, |
| Agent执行 | Agent执行 | 查看你的预览环境状态和范围 |
| Agent执行(自身创建的环境) | Agent执行(自身创建的环境) | 缩容你拥有的预览环境 |
| Agent执行 | Agent执行 | 唤醒休眠的预览环境 |
| 用户执行(或自身创建的环境) | 自身创建的环境/有策略授权 | 销毁预览环境及其命名空间 |
okteto preview deploy-b/--branch--repository-s/--scope personal|globalglobal-v/--var KEY=VALUE--sourceUrl <pr-url>-t/--timeout5m0s-w/--waittrue-f/--file--label--dependenciesCommon mistakes to avoid
需避免的常见错误
- Expecting local changes in the preview. Previews deploy from the pushed branch. Commit and push before , and push again to update it.
okteto preview deploy - Omitting the preview name in CI. A nameless deploy gets a random name, so every run creates a new preview and the cleanup job orphans them all. Key the name to the PR () or branch slug.
pr-<number> - Mismatched names between deploy and destroy workflows. The destroy job must use the exact same name expression as the deploy job, or previews leak.
- Assuming defaults to
--scope. The default ispersonal— visible to the whole organization. Sayglobalwhen the work isn't ready to share.--scope personal - Using a preview as a dev environment. No file sync, no . To iterate on code, use a namespace dev environment (
okteto upskill) and keep the preview for reviewers.okteto - Running instead of
okteto endpoints. The former targets the active namespace of your context, not the preview.okteto preview endpoints <name> - Setting on the preview workflow. Cancelling an in-progress deploy leaves the preview inconsistent and leaks resources. Queue per-PR with
cancel-in-progress: true.cancel-in-progress: false - Double-posting the URL in CI. With set,
GITHUB_TOKENalready comments on the PR. Add your ownokteto/deploy-previewonly when deploying from outside CI.gh pr comment - Destroying a preview you don't own. CI-owned, shared/global, or someone else's previews are off-limits without explicit instruction — same rule as in the
okteto destroyskill.okteto - Destroying to "fix" a broken preview. Redeploy with the same name instead; it updates in place.
- 期望本地更改同步到预览环境。预览环境从已推送的分支部署。执行前需提交并推送代码,更新预览环境需再次推送。
okteto preview deploy - CI中省略预览环境名称。无名称的部署会生成随机名称,导致每次运行都创建新的预览环境,清理任务无法处理遗留环境。需将名称与PR()或分支缩写绑定。
pr-<编号> - 部署与销毁工作流名称不匹配。销毁任务必须使用与部署任务完全相同的名称表达式,否则会遗留预览环境。
- 默认为
--scope。默认值为personal——组织内所有成员可见。未准备好共享的工作需显式指定global。--scope personal - 将预览环境用作开发环境。不支持文件同步和。代码迭代请使用命名空间开发环境(
okteto up技能),预览环境仅用于评审。okteto - 执行而非
okteto endpoints。前者针对上下文的活动命名空间,而非预览环境。okteto preview endpoints <name> - 预览工作流设置。取消正在进行的部署会导致预览环境不一致并遗留资源。按PR排队需设置
cancel-in-progress: true。cancel-in-progress: false - CI中重复发布URL。设置后,
GITHUB_TOKEN已自动发布PR评论。仅在CI外部署时才需自行添加okteto/deploy-preview步骤。gh pr comment - 销毁非你拥有的预览环境。CI托管、共享/全局或他人的预览环境未经明确授权不可销毁——与技能中
okteto的规则一致。okteto destroy - 用“修复”损坏的预览环境。应使用相同名称重新部署,实现就地更新。
destroy