- 概述
- 开始使用
- 概念
- 使用 UiPath CLI
- 操作指南
- CI/CD 方法
- 命令参考
- 迁移
- 参考与支持
CI/CD 秘钥:GitHub Actions
完整的 GitHub Actions 工作流,用于身份验证、打包、发布、部署 UiPath 解决方案以及运行 Test Manager 测试。
此页面为您提供完整的.github/workflows/deploy.yml ,用于安装 CLI,使用外部应用程序进行身份验证,打包并发布 UiPath 解决方案,将其部署到 Orchestrator,以及针对部署运行 Test Manager 套件。将其拖放到您的存储库中,添加两个密码,然后即可运行。
有关基本原则(身份验证、缓存、工具预安装、版本固定),请参阅操作方法:从 CI 部署到 Orchestrator 。本页面重点介绍 GitHub 操作语法。
要在编码智能体拉取请求到达此管道之前对其进行审核,请参阅CI/CD 秘钥:智能体拉取请求审核。
先决条件
在复制以下 YAML 之前:
- 在 UiPath 中使用管道所需的
OR.*作用域创建外部应用程序。请参阅身份验证 — 流程2 。 - 将密码存储在存储库(或组织/环境)设置中:
- 设置 → “密码和变量” → 操作 →新建存储库密码。
- 将
UIPATH_CLIENT_ID和UIPATH_CLIENT_SECRET添加为密码。 - 将
UIPATH_TENANT添加为变量(非密码 — 不敏感)。 - 有关确切的用户界面步骤、等效的
gh命令,以及何时使用密码而不是变量,请参阅配置存储库。
- Commit a frozen
.uipath/config.jsonat the repository root. The pipeline reads the CLI, tool, and skills versions from it. See Freezing a CI pipeline. - 如果您需要测试作业,请配置 Test Manager 项目和测试集。将
TEST_SET_KEY(例如存储库变量中添加PROJECT:42)和PROJECT_KEY。请参阅操作方法:从 CLI 运行测试。
.github/workflows/deploy.yml
name: Deploy UiPath Solution
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
NODE_VERSION: '22'
SOLUTION_NAME: 'my-solution'
DEPLOYMENT_NAME: 'my-solution' # the deployment's identity: keep it the same on every run
SOLUTION_DIR: './my-solution'
OUTPUT_DIR: './dist'
jobs:
build:
name: Pack Solution
runs-on: ubuntu-latest
outputs:
solution_version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Compute version
id: version
run: echo "version=1.2.0-ci.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache npm global (@uipath/cli)
uses: actions/cache@v4
with:
path: ~/.npm-global/lib/node_modules
key: uip-${{ hashFiles('.uipath/config.json') }}-${{ runner.os }}
- name: Install UiPath CLI
shell: bash
run: |
set -euo pipefail
mkdir -p "$HOME/.npm-global"
npm config set prefix "$HOME/.npm-global"
echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.npm-global/bin:$PATH"
CLI_PIN=$(node -p "require('./.uipath/config.json').versions.cli") || exit 1
if ! command -v uip >/dev/null; then
npm install -g "@uipath/cli@$CLI_PIN"
fi
uip update
uip --version
- name: Pack Solution
id: pack
shell: bash
run: |
set -euo pipefail
mkdir -p "$OUTPUT_DIR"
uip solution pack "$SOLUTION_DIR" "$OUTPUT_DIR" \
--name "$SOLUTION_NAME" \
--version "${{ steps.version.outputs.version }}"
ARTIFACT=$(find "$OUTPUT_DIR" -maxdepth 1 -name "*.zip" | head -1)
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
with:
name: solution-zip
path: ${{ steps.pack.outputs.artifact }}
deploy:
name: Publish and deploy
needs: build
if: github.event_name != 'pull_request' # pull requests pack only; they never touch the tenant
runs-on: ubuntu-latest
environment: uipath-prod # attach approval gates here if needed
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache npm global (@uipath/cli)
uses: actions/cache@v4
with:
path: ~/.npm-global/lib/node_modules
key: uip-${{ hashFiles('.uipath/config.json') }}-${{ runner.os }}
- name: Install UiPath CLI
shell: bash
run: |
set -euo pipefail
mkdir -p "$HOME/.npm-global"
npm config set prefix "$HOME/.npm-global"
echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.npm-global/bin:$PATH"
CLI_PIN=$(node -p "require('./.uipath/config.json').versions.cli") || exit 1
if ! command -v uip >/dev/null; then
npm install -g "@uipath/cli@$CLI_PIN"
fi
uip update
- uses: actions/download-artifact@v4
with:
name: solution-zip
path: ${{ env.OUTPUT_DIR }}
- name: Authenticate
shell: bash
env:
UIPATH_CLIENT_ID: ${{ secrets.UIPATH_CLIENT_ID }}
UIPATH_CLIENT_SECRET: ${{ secrets.UIPATH_CLIENT_SECRET }}
UIPATH_TENANT: ${{ vars.UIPATH_TENANT }}
run: |
set -euo pipefail
uip login \
--client-id env.UIPATH_CLIENT_ID \
--client-secret env.UIPATH_CLIENT_SECRET \
--tenant "$UIPATH_TENANT"
- name: Publish to tenant feed
shell: bash
run: |
set -euo pipefail
ARTIFACT=$(find "$OUTPUT_DIR" -maxdepth 1 -name "*.zip" | head -1)
uip solution publish "$ARTIFACT"
- name: Deploy to Orchestrator
shell: bash
run: |
set -euo pipefail
uip solution deploy run \
--name "$DEPLOYMENT_NAME" \
--package-name "$SOLUTION_NAME" \
--package-version "${{ needs.build.outputs.solution_version }}" \
--folder-name MySolution \
--parent-folder-path Shared
test:
name: Run Test Manager suite
needs: deploy
if: ${{ vars.TEST_SET_KEY != '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache npm global (@uipath/cli)
uses: actions/cache@v4
with:
path: ~/.npm-global/lib/node_modules
key: uip-${{ hashFiles('.uipath/config.json') }}-${{ runner.os }}
- name: Install CLI and authenticate
shell: bash
env:
UIPATH_CLIENT_ID: ${{ secrets.UIPATH_CLIENT_ID }}
UIPATH_CLIENT_SECRET: ${{ secrets.UIPATH_CLIENT_SECRET }}
UIPATH_TENANT: ${{ vars.UIPATH_TENANT }}
run: |
set -euo pipefail
mkdir -p "$HOME/.npm-global"
npm config set prefix "$HOME/.npm-global"
echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.npm-global/bin:$PATH"
CLI_PIN=$(node -p "require('./.uipath/config.json').versions.cli") || exit 1
if ! command -v uip >/dev/null; then
npm install -g "@uipath/cli@$CLI_PIN"
fi
uip update
uip login \
--client-id env.UIPATH_CLIENT_ID \
--client-secret env.UIPATH_CLIENT_SECRET \
--tenant "$UIPATH_TENANT"
- name: Launch, wait, verify
shell: bash
env:
TEST_SET_KEY: ${{ vars.TEST_SET_KEY }}
PROJECT_KEY: ${{ vars.PROJECT_KEY }}
run: |
set -euo pipefail
EXECUTION_ID=$(uip tm testsets run \
--test-set-key "$TEST_SET_KEY" \
--output-filter "ExecutionId" \
--output plain)
echo "started execution $EXECUTION_ID"
code=0
uip tm wait \
--execution-id "$EXECUTION_ID" \
--project-key "$PROJECT_KEY" \
--timeout 1800 || code=$?
if [ "$code" -eq 4 ]; then
echo "::error::test run did not finish within 30 minutes"
exit 4
fi
uip tm report get \
--execution-id "$EXECUTION_ID" \
--project-key "$PROJECT_KEY"
FAILED=$(uip tm report get \
--execution-id "$EXECUTION_ID" \
--project-key "$PROJECT_KEY" \
--output-filter "Failed" \
--output plain)
if [ "$FAILED" -gt 0 ]; then
echo "::error::$FAILED test case(s) failed"
exit 1
fi
if [ "$code" -ne 0 ]; then
echo "::error::wait failed or the run was cancelled (exit $code)"
exit "$code"
fi
name: Deploy UiPath Solution
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
NODE_VERSION: '22'
SOLUTION_NAME: 'my-solution'
DEPLOYMENT_NAME: 'my-solution' # the deployment's identity: keep it the same on every run
SOLUTION_DIR: './my-solution'
OUTPUT_DIR: './dist'
jobs:
build:
name: Pack Solution
runs-on: ubuntu-latest
outputs:
solution_version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Compute version
id: version
run: echo "version=1.2.0-ci.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache npm global (@uipath/cli)
uses: actions/cache@v4
with:
path: ~/.npm-global/lib/node_modules
key: uip-${{ hashFiles('.uipath/config.json') }}-${{ runner.os }}
- name: Install UiPath CLI
shell: bash
run: |
set -euo pipefail
mkdir -p "$HOME/.npm-global"
npm config set prefix "$HOME/.npm-global"
echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.npm-global/bin:$PATH"
CLI_PIN=$(node -p "require('./.uipath/config.json').versions.cli") || exit 1
if ! command -v uip >/dev/null; then
npm install -g "@uipath/cli@$CLI_PIN"
fi
uip update
uip --version
- name: Pack Solution
id: pack
shell: bash
run: |
set -euo pipefail
mkdir -p "$OUTPUT_DIR"
uip solution pack "$SOLUTION_DIR" "$OUTPUT_DIR" \
--name "$SOLUTION_NAME" \
--version "${{ steps.version.outputs.version }}"
ARTIFACT=$(find "$OUTPUT_DIR" -maxdepth 1 -name "*.zip" | head -1)
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
with:
name: solution-zip
path: ${{ steps.pack.outputs.artifact }}
deploy:
name: Publish and deploy
needs: build
if: github.event_name != 'pull_request' # pull requests pack only; they never touch the tenant
runs-on: ubuntu-latest
environment: uipath-prod # attach approval gates here if needed
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache npm global (@uipath/cli)
uses: actions/cache@v4
with:
path: ~/.npm-global/lib/node_modules
key: uip-${{ hashFiles('.uipath/config.json') }}-${{ runner.os }}
- name: Install UiPath CLI
shell: bash
run: |
set -euo pipefail
mkdir -p "$HOME/.npm-global"
npm config set prefix "$HOME/.npm-global"
echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.npm-global/bin:$PATH"
CLI_PIN=$(node -p "require('./.uipath/config.json').versions.cli") || exit 1
if ! command -v uip >/dev/null; then
npm install -g "@uipath/cli@$CLI_PIN"
fi
uip update
- uses: actions/download-artifact@v4
with:
name: solution-zip
path: ${{ env.OUTPUT_DIR }}
- name: Authenticate
shell: bash
env:
UIPATH_CLIENT_ID: ${{ secrets.UIPATH_CLIENT_ID }}
UIPATH_CLIENT_SECRET: ${{ secrets.UIPATH_CLIENT_SECRET }}
UIPATH_TENANT: ${{ vars.UIPATH_TENANT }}
run: |
set -euo pipefail
uip login \
--client-id env.UIPATH_CLIENT_ID \
--client-secret env.UIPATH_CLIENT_SECRET \
--tenant "$UIPATH_TENANT"
- name: Publish to tenant feed
shell: bash
run: |
set -euo pipefail
ARTIFACT=$(find "$OUTPUT_DIR" -maxdepth 1 -name "*.zip" | head -1)
uip solution publish "$ARTIFACT"
- name: Deploy to Orchestrator
shell: bash
run: |
set -euo pipefail
uip solution deploy run \
--name "$DEPLOYMENT_NAME" \
--package-name "$SOLUTION_NAME" \
--package-version "${{ needs.build.outputs.solution_version }}" \
--folder-name MySolution \
--parent-folder-path Shared
test:
name: Run Test Manager suite
needs: deploy
if: ${{ vars.TEST_SET_KEY != '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache npm global (@uipath/cli)
uses: actions/cache@v4
with:
path: ~/.npm-global/lib/node_modules
key: uip-${{ hashFiles('.uipath/config.json') }}-${{ runner.os }}
- name: Install CLI and authenticate
shell: bash
env:
UIPATH_CLIENT_ID: ${{ secrets.UIPATH_CLIENT_ID }}
UIPATH_CLIENT_SECRET: ${{ secrets.UIPATH_CLIENT_SECRET }}
UIPATH_TENANT: ${{ vars.UIPATH_TENANT }}
run: |
set -euo pipefail
mkdir -p "$HOME/.npm-global"
npm config set prefix "$HOME/.npm-global"
echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.npm-global/bin:$PATH"
CLI_PIN=$(node -p "require('./.uipath/config.json').versions.cli") || exit 1
if ! command -v uip >/dev/null; then
npm install -g "@uipath/cli@$CLI_PIN"
fi
uip update
uip login \
--client-id env.UIPATH_CLIENT_ID \
--client-secret env.UIPATH_CLIENT_SECRET \
--tenant "$UIPATH_TENANT"
- name: Launch, wait, verify
shell: bash
env:
TEST_SET_KEY: ${{ vars.TEST_SET_KEY }}
PROJECT_KEY: ${{ vars.PROJECT_KEY }}
run: |
set -euo pipefail
EXECUTION_ID=$(uip tm testsets run \
--test-set-key "$TEST_SET_KEY" \
--output-filter "ExecutionId" \
--output plain)
echo "started execution $EXECUTION_ID"
code=0
uip tm wait \
--execution-id "$EXECUTION_ID" \
--project-key "$PROJECT_KEY" \
--timeout 1800 || code=$?
if [ "$code" -eq 4 ]; then
echo "::error::test run did not finish within 30 minutes"
exit 4
fi
uip tm report get \
--execution-id "$EXECUTION_ID" \
--project-key "$PROJECT_KEY"
FAILED=$(uip tm report get \
--execution-id "$EXECUTION_ID" \
--project-key "$PROJECT_KEY" \
--output-filter "Failed" \
--output plain)
if [ "$FAILED" -gt 0 ]; then
echo "::error::$FAILED test case(s) failed"
exit 1
fi
if [ "$code" -ne 0 ]; then
echo "::error::wait failed or the run was cancelled (exit $code)"
exit "$code"
fi
演练
构建作业
actions/checkout@v4checks out the repository, which holds the frozen.uipath/config.json. The CLI reads that file from the current folder upward, so every job that runsuipchecks out the repository first.actions/setup-node@v4将节点固定到由NODE_VERSION指定的主要版本。CLI 要求 Node 22+。actions/cache@v4caches the npm globalnode_modulesdirectory, keyed on the hash of.uipath/config.jsonand the runner OS. When the cache hits, the install step'sif ! command -v uipguard skips thenpm install.- Install step configures a user-local npm prefix (no
sudoneeded on GitHub-hosted runners), adds it toGITHUB_PATHso later steps see theuipcommand, and installs the CLI at the version inversions.cli.uip updatethen puts the CLI and each pinned tool on their pins — no explicituip tools installis needed. See Freezing a CI pipeline. - 打包步骤使用根据
uip solution pack构建的显式--version调用github.run_number(单调,存储库中每次运行唯一)。此步骤使用find捕获生成的.zip路径,而不是对文件名进行硬编码 — 即使 CLI 命名约定发生更改,也能保持方法稳定。 actions/upload-artifact@v4上传捕获的.zip,以便deploy作业可以在下次运行中下载它。outputs.solution_version将计算的版本传播到deploy作业,这是在同一工作流中的作业之间共享值的最简单方法。
部署作业
- Checks out the repository and re-installs the CLI —
needs: buildforces the job order, but each job runs on a fresh runner, with no repository and no CLI. The cache should hit on the second install. actions/download-artifact@v4将solution-zip拉取到$OUTPUT_DIR中。- 身份验证步骤通过步骤的
env:块传递密码,然后uip login通过env.前缀读取密码。env.VAR_NAME前缀是受支持的向命令行隐藏机密信息的方式 — 请参阅身份验证 — env.VAR_NAME 前缀。请勿写入--client-secret "${{ secrets.UIPATH_CLIENT_SECRET }}"— 会将值嵌入到呈现的命令和步骤日志中。 - Publish + deploy steps use
uip solution publishanduip solution deploy run. The deployment is keyed on--name, soDEPLOYMENT_NAMEstays the same on every run:- The first run creates the deployment and its folder,
Shared/MySolution. - Every later run upgrades that same deployment in place to the new version. The folder and the provisioned resources stay, and values already set on them (for example a credential asset's secret) are kept.
--folder-nameand--parent-folder-pathapply only to the first run. - Do not put
github.run_numberor a commit SHA in--name. Each new name is a new deployment, and because the folder name is already taken, Orchestrator createsMySolution 1,MySolution 2, and so on: one folder per run. - Under the client-credentials login this pipeline uses, the CLI's "already deployed" check only warns; it does not stop the run.
- Once the deployment exists,
uip solution deploy upgrade --name "$DEPLOYMENT_NAME" --package-name "$SOLUTION_NAME" --version <version>does the same upgrade. Unlikedeploy run, it fails when no deployment has that name, instead of creating one. Seedeploy upgrade. - If you add
--config-file, keep only the resources you change in the file. Each resource the file names is applied as written on every run, so a file straight fromdeploy config getsets those resources back to the package defaults.
- The first run creates the deployment and its folder,
if: github.event_name != 'pull_request'limits pull-request runs to thebuildjob. Without it, every pull request would upgrade the production deployment to unmerged code. To deploy pull requests, give each one its own deployment name in a test tenant: see A copy per pull request.environment: uipath-prod将作业与部署环境绑定。您可以在环境中配置所需的审核人、等待计时器和部署分支。将这些内容配置在用户界面中,并保留 YAML 声明格式。
测试作业
仅在设置了TEST_SET_KEY存储库变量时运行,否则if:防护机制会跳过它。shell 块是“操作方法:从 CLI 运行测试” 中的规范“启动”→“等待”→“验证” 模式:
uip tm testsets run启动并返回ExecutionId。uip tm waitblocks until terminal state. Exit4means timeout onwait, and exit1means a test failed or the run was cancelled; the outcome is reported via::error::so it surfaces in the Actions UI.uip tm report get为Data.Failed,并且该步骤将在1失败时退出。
常见变体
跨环境提升
使用不同的密码添加依赖于第一个 deploy 作业的第二个作业:
deploy-stage:
needs: build
environment: uipath-stage
# …same steps as `deploy`, using ${{ secrets.UIPATH_STAGE_CLIENT_ID }} etc.
deploy-prod:
needs: deploy-stage
environment: uipath-prod # add "Required reviewers" in the environment settings
# …same steps as `deploy`, using ${{ secrets.UIPATH_PROD_CLIENT_ID }} etc.
deploy-stage:
needs: build
environment: uipath-stage
# …same steps as `deploy`, using ${{ secrets.UIPATH_STAGE_CLIENT_ID }} etc.
deploy-prod:
needs: deploy-stage
environment: uipath-prod # add "Required reviewers" in the environment settings
# …same steps as `deploy`, using ${{ secrets.UIPATH_PROD_CLIENT_ID }} etc.
审批网关位于环境设置中 — needs:链强制执行顺序。请参阅操作方法:打包并发布解决方案 — 跨租户提升一个包。
回滚
Add a workflow_dispatch input and a guarded job that upgrades the existing deployment back to a specific version. It uses deploy upgrade --name rather than deploy run: deploy upgrade never creates a deployment, so a mistyped name fails instead of installing a fresh copy in a new folder:
on:
workflow_dispatch:
inputs:
rollback_version:
description: 'Version to roll back to (e.g. 1.1.9)'
required: false
type: string
jobs:
rollback:
if: ${{ github.event.inputs.rollback_version != '' }}
runs-on: ubuntu-latest
# …install + auth…
steps:
- name: Roll back to previous version
run: |
set -euo pipefail
uip solution deploy upgrade \
--name "$DEPLOYMENT_NAME" \
--package-name "$SOLUTION_NAME" \
--version "${{ github.event.inputs.rollback_version }}"
on:
workflow_dispatch:
inputs:
rollback_version:
description: 'Version to roll back to (e.g. 1.1.9)'
required: false
type: string
jobs:
rollback:
if: ${{ github.event.inputs.rollback_version != '' }}
runs-on: ubuntu-latest
# …install + auth…
steps:
- name: Roll back to previous version
run: |
set -euo pipefail
uip solution deploy upgrade \
--name "$DEPLOYMENT_NAME" \
--package-name "$SOLUTION_NAME" \
--version "${{ github.event.inputs.rollback_version }}"
deploy upgrade preserves the deployment's existing configuration — asset/credential values already set on it aren't reset to package defaults. Any published version of the package is accepted, including an older one. Extend the deploy job's guard to if: github.event_name != 'pull_request' && github.event.inputs.rollback_version == '', so a rollback run does not also deploy the new build to the same deployment.
使用“操作触发”→“部署 UiPath 解决方案”→“运行工作流并输入回滚版本”。有关破坏性回滚(卸载 + solution packages delete ),请参阅操作方法:打包并发布解决方案 — 回滚。
A separate copy per run
For short-lived side-by-side copies (for example a preview copy per run in a test tenant), vary the folder name together with the deployment name, so each copy gets a folder you can recognize instead of MySolution 1, MySolution 2:
uip solution deploy run \
--name "${DEPLOYMENT_NAME}-${{ github.run_number }}" \
--package-name "$SOLUTION_NAME" \
--package-version "${{ needs.build.outputs.solution_version }}" \
--folder-name "MySolution-${{ github.run_number }}" \
--parent-folder-path Shared \
--yes
uip solution deploy run \
--name "${DEPLOYMENT_NAME}-${{ github.run_number }}" \
--package-name "$SOLUTION_NAME" \
--package-version "${{ needs.build.outputs.solution_version }}" \
--folder-name "MySolution-${{ github.run_number }}" \
--parent-folder-path Shared \
--yes
--yes skips the "already deployed" check, since a second copy is the intent here. Nothing removes these copies: uninstall each one when you are done with it, with uip solution deploy uninstall.
A copy per pull request
To review a pull request on a running copy, deploy it under a name and folder of its own in a test tenant, and uninstall that copy when the pull request closes. The name stays the same for the life of the pull request: its first run creates the copy, and every later push updates that copy in place.
Add this job to deploy.yml:
deploy-pr:
name: Deploy this pull request's copy
needs: build
# Pull requests from this repository only: GitHub gives no secrets to a fork's pull request.
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
environment: uipath-pr-preview # its secrets and UIPATH_TENANT point at a test tenant
concurrency:
group: uipath-pr-${{ github.event.pull_request.number }}
cancel-in-progress: false
steps:
# …same checkout, install, download, authenticate and publish steps as `deploy`…
- name: Deploy to Orchestrator
shell: bash
run: |
set -euo pipefail
uip solution deploy run \
--name "${DEPLOYMENT_NAME}-pr-${{ github.event.pull_request.number }}" \
--package-name "$SOLUTION_NAME" \
--package-version "${{ needs.build.outputs.solution_version }}" \
--folder-name "MySolution-pr-${{ github.event.pull_request.number }}" \
--parent-folder-path Shared \
--yes
deploy-pr:
name: Deploy this pull request's copy
needs: build
# Pull requests from this repository only: GitHub gives no secrets to a fork's pull request.
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
environment: uipath-pr-preview # its secrets and UIPATH_TENANT point at a test tenant
concurrency:
group: uipath-pr-${{ github.event.pull_request.number }}
cancel-in-progress: false
steps:
# …same checkout, install, download, authenticate and publish steps as `deploy`…
- name: Deploy to Orchestrator
shell: bash
run: |
set -euo pipefail
uip solution deploy run \
--name "${DEPLOYMENT_NAME}-pr-${{ github.event.pull_request.number }}" \
--package-name "$SOLUTION_NAME" \
--package-version "${{ needs.build.outputs.solution_version }}" \
--folder-name "MySolution-pr-${{ github.event.pull_request.number }}" \
--parent-folder-path Shared \
--yes
Then add the cleanup as its own workflow, .github/workflows/pr-cleanup.yml, so closing a pull request does not also run the build job:
name: Remove the pull request's UiPath copy
on:
pull_request:
types: [ closed ]
branches: [ main ]
env:
NODE_VERSION: '22'
DEPLOYMENT_NAME: 'my-solution'
jobs:
cleanup:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
environment: uipath-pr-preview
concurrency:
group: uipath-pr-${{ github.event.pull_request.number }}
cancel-in-progress: false
steps:
# …same checkout, install and authenticate steps as `deploy`…
- name: Uninstall this pull request's copy
shell: bash
run: |
set -euo pipefail
uip solution deploy uninstall \
"${DEPLOYMENT_NAME}-pr-${{ github.event.pull_request.number }}" \
--yes
name: Remove the pull request's UiPath copy
on:
pull_request:
types: [ closed ]
branches: [ main ]
env:
NODE_VERSION: '22'
DEPLOYMENT_NAME: 'my-solution'
jobs:
cleanup:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
environment: uipath-pr-preview
concurrency:
group: uipath-pr-${{ github.event.pull_request.number }}
cancel-in-progress: false
steps:
# …same checkout, install and authenticate steps as `deploy`…
- name: Uninstall this pull request's copy
shell: bash
run: |
set -euo pipefail
uip solution deploy uninstall \
"${DEPLOYMENT_NAME}-pr-${{ github.event.pull_request.number }}" \
--yes
- The pull request number in
--nameand--folder-namegives each pull request its own deployment and its own folder, for exampleShared/MySolution-pr-42. Thedeployjob keeps deploying production underDEPLOYMENT_NAME.--yesskips the "already deployed" check, since the test tenant is expected to hold other pull requests' copies of the package. environment: uipath-pr-previewholds the test tenant'sUIPATH_CLIENT_ID,UIPATH_CLIENT_SECRETandUIPATH_TENANT. An environment's secrets and variables take precedence over the repository's ones of the same name, so the copied steps log in to the test tenant unchanged. Never point this environment at the production tenant.- The
head.repocheck skips pull requests from forks. They get no secrets, so their login would fail. concurrencyruns one deploy or cleanup at a time per pull request, across both workflows. While an operation on a deployment runs, the server refuses another deploy under that name.- The cleanup runs when the pull request closes, merged or not.
uip solution deploy uninstallremoves the copy's resources and its folder, and cannot be undone. When the pull request has no copy to remove (for example, its first deploy never finished), the cleanup run fails, and the command'sInstructionssay why.
跳过测试
设置(或未设置) TEST_SET_KEY存储库变量。if: ${{ vars.TEST_SET_KEY != '' }}防护机制会跳过整个作业。
常见错误
${{ secrets.X }}插值。它将替代逐步渲染层。如果您将密码直接放入run:命令行中,该值将成为呈现脚本和步骤日志的一部分,除非 GitHub 对其进行掩码。始终通过env:路由机密信息,并在uip中使用env.VAR_NAME读取机密信息。$GITHUB_PATH与$PATH。在一个步骤中导出PATH=…,不会进入下一个步骤。使用echo "…" >> "$GITHUB_PATH"在同一运行器上的步骤中添加路径。strict shell options。以run:开头的每个多行set -euo pipefail— 如果没有它,失败的uip solution pack后可以“成功”发布过时的工件。请参阅脚本编写模式—严格 shell 选项。- Cache false-positives. If the cache key does not change when the freeze changes, the runner restores the old CLI and tools, and
uip updatereinstalls them on every run. The key in this YAML hashes.uipath/config.jsonfor this reason. - 缓存路径与 npm 前缀耦合。缓存块使用
~/.npm-global/lib/node_modules,而后者仅在安装步骤运行时才有效。npm config set prefix "$HOME/.npm-global"如果您更改前缀(例如在约定为%APPDATA%\npm\node_modules自托管 Windows 运行器上),则缓存path:和npm config set prefix行必须一起移动。在非 ubuntu 最新版的运行器上,首先使用- run: npm root -g转储真实路径,然后镜像其报告的任何内容。
另请参阅
- 操作方法:从 CI 部署到 Orchestrator — 与平台无关的指南。
- 操作方法:打包并发布解决方案— 版本控制和回滚。
- 操作方法:从 CLI 运行测试— 启动 → 等待 → 验证模式。
- CI/CD 秘钥:智能体拉取请求审核— 使用编码智能体审核更改并控制合并。
- CI/CD 秘方:Azure Pipelines 、 Jenkins 、 GitLab CI — 其他平台中的相同管道。