From 1949a48d969a7e73d4c8efe55d801a579a358a2e Mon Sep 17 00:00:00 2001 From: Lyda <1829913225@qq.com> Date: Thu, 21 Aug 2025 18:19:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=84=E8=8C=83=E5=8C=96=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E6=96=87=E4=BB=B6=E5=92=8C=E6=96=87=E6=A1=A3=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E6=A0=BC=E5=BC=8F=EF=BC=8C=E4=BC=98=E5=8C=96=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=8F=8F=E8=BF=B0=EF=BC=8C=E6=8F=90=E5=8D=87=E5=8F=AF?= =?UTF-8?q?=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trigger-version/README.md | 36 +++++++++---------- trigger-version/action.yml | 2 +- .../examples/latest-version-demo.yml | 12 +++---- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/trigger-version/README.md b/trigger-version/README.md index fbab743..4a4cb33 100644 --- a/trigger-version/README.md +++ b/trigger-version/README.md @@ -15,24 +15,24 @@ ## 输入参数 -| 参数名 | 描述 | 必需 | 默认值 | -| -------------------------- | ------------------------------ | ---- | ------- | -| `version-prefix` | 版本前缀,用于匹配版本标签或分支 | 否 | `v` | -| `use-latest-version` | 在非版本触发时是否使用最新版本 | 否 | `false` | +| 参数名 | 描述 | 必需 | 默认值 | +| -------------------- | -------------------------------- | ---- | ------- | +| `version-prefix` | 版本前缀,用于匹配版本标签或分支 | 否 | `v` | +| `use-latest-version` | 在非版本触发时是否使用最新版本 | 否 | `false` | ## 输出参数 -| 参数名 | 描述 | 示例值 | -| ------------------------------ | ---------------------------- | ------------------------------- | -| `ref-type` | 引用类型 | `tag` 或 `branch` | -| `ref-name` | 引用名称 | `v1.2.3`、`main`、`feature/xxx` | -| `is-version-trigger` | 是否为版本触发 | `true` 或 `false` | -| `trigger-version` | 触发的版本号(标准化格式) | `v1.2.3` | -| `version-with-dash` | 版本号,点替换为横线 | `v1-2-3` | -| `trigger-source` | 触发源 | `tag` 或 `branch` | -| `full-ref` | 完整的 Git 引用 | `refs/tags/v1.2.3` | -| `latest-version` | 仓库中的最新版本号 | `v1.2.3` | -| `latest-version-with-dash` | 最新版本号,点替换为横线 | `v1-2-3` | +| 参数名 | 描述 | 示例值 | +| -------------------------- | -------------------------- | ------------------------------- | +| `ref-type` | 引用类型 | `tag` 或 `branch` | +| `ref-name` | 引用名称 | `v1.2.3`、`main`、`feature/xxx` | +| `is-version-trigger` | 是否为版本触发 | `true` 或 `false` | +| `trigger-version` | 触发的版本号(标准化格式) | `v1.2.3` | +| `version-with-dash` | 版本号,点替换为横线 | `v1-2-3` | +| `trigger-source` | 触发源 | `tag` 或 `branch` | +| `full-ref` | 完整的 Git 引用 | `refs/tags/v1.2.3` | +| `latest-version` | 仓库中的最新版本号 | `v1.2.3` | +| `latest-version-with-dash` | 最新版本号,点替换为横线 | `v1-2-3` | ## 环境变量 @@ -67,7 +67,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: - fetch-depth: 0 # 必需:获取完整历史以获取所有标签 + fetch-depth: 0 # 必需:获取完整历史以获取所有标签 - name: 获取版本信息 id: version-info @@ -94,7 +94,7 @@ jobs: ### 使用最新版本功能 -```yaml +````yaml - name: 获取版本信息(启用最新版本) id: version-info uses: ./trigger-version @@ -119,7 +119,7 @@ jobs: uses: actions/xgj/trigger-version@v1 with: version-prefix: "release-" -``` +```` ### 完整的 CI/CD 流程 diff --git a/trigger-version/action.yml b/trigger-version/action.yml index b42b740..8d4734f 100644 --- a/trigger-version/action.yml +++ b/trigger-version/action.yml @@ -187,7 +187,7 @@ runs: echo "trigger_source=$TRIGGER_SOURCE" >> $GITHUB_OUTPUT echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT echo "latest_version_with_dash=$LATEST_VERSION_WITH_DASH" >> $GITHUB_OUTPUT - + # 输出摘要信息 echo "" echo "=== 版本信息摘要 ===" diff --git a/trigger-version/examples/latest-version-demo.yml b/trigger-version/examples/latest-version-demo.yml index 4fbf060..788d521 100644 --- a/trigger-version/examples/latest-version-demo.yml +++ b/trigger-version/examples/latest-version-demo.yml @@ -1,9 +1,9 @@ name: Latest Version Demo on: push: - branches: [ main, develop ] + branches: [main, develop] pull_request: - branches: [ main ] + branches: [main] jobs: show-version-info: @@ -12,13 +12,13 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: - fetch-depth: 0 # 获取完整历史,确保能获取所有标签 + fetch-depth: 0 # 获取完整历史,确保能获取所有标签 - name: Get Version Info id: version uses: ./trigger-version with: - version-prefix: 'v' + version-prefix: "v" use-latest-version: true - name: Display Version Information @@ -43,10 +43,10 @@ jobs: run: | echo "使用最新版本进行部署: ${{ steps.version.outputs.latest-version }}" echo "镜像标签: myapp:${{ steps.version.outputs.latest-version-with-dash }}" - + # 示例:构建 Docker 镜像 # docker build -t myapp:${{ steps.version.outputs.latest-version-with-dash }} . - + # 示例:设置 Kubernetes 部署 # kubectl set image deployment/myapp container=myapp:${{ steps.version.outputs.latest-version-with-dash }}