From 5b75a9c95597451f53a2cf9c232826ee031ad4a9 Mon Sep 17 00:00:00 2001 From: Lyda <1829913225@qq.com> Date: Thu, 21 Aug 2025 09:55:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=20trigger-versi?= =?UTF-8?q?on=20GitHub=20Action=20=E7=9A=84=E4=BD=BF=E7=94=A8=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E7=BB=9F=E4=B8=80=E4=BD=BF=E7=94=A8=20action?= =?UTF-8?q?s/xgj/trigger-version@v1=EF=BC=8C=E7=A1=AE=E4=BF=9D=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E7=A4=BA=E4=BE=8B=E4=B8=8E=E5=AE=9E=E9=99=85=E7=94=A8?= =?UTF-8?q?=E6=B3=95=E4=B8=80=E8=87=B4=EF=BC=8C=E6=8F=90=E5=8D=87=E5=8F=AF?= =?UTF-8?q?=E7=BB=B4=E6=8A=A4=E6=80=A7=E5=92=8C=E4=B8=80=E8=87=B4=E6=80=A7?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trigger-version/README.md | 6 +++--- trigger-version/examples/basic-usage.yml | 2 +- trigger-version/examples/conditional-deployment.yml | 2 +- trigger-version/examples/custom-prefix.yml | 10 +++++----- trigger-version/examples/full-cicd.yml | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/trigger-version/README.md b/trigger-version/README.md index 7247fc4..2f5ab47 100644 --- a/trigger-version/README.md +++ b/trigger-version/README.md @@ -57,7 +57,7 @@ jobs: steps: - name: 获取版本信息 id: version-info - uses: ./trigger-version + uses: actions/xgj/trigger-version@v1 - name: 显示版本信息 run: | @@ -80,7 +80,7 @@ jobs: ```yaml - name: 获取版本信息(自定义前缀) id: version-info - uses: ./trigger-version + uses: actions/xgj/trigger-version@v1 with: version-prefix: "release-" ``` @@ -104,7 +104,7 @@ jobs: steps: - name: 获取版本信息 id: version-info - uses: ./trigger-version + uses: actions/xgj/trigger-version@v1 - name: 检查是否需要部署 id: check-deploy diff --git a/trigger-version/examples/basic-usage.yml b/trigger-version/examples/basic-usage.yml index fc8d477..ae2dc01 100644 --- a/trigger-version/examples/basic-usage.yml +++ b/trigger-version/examples/basic-usage.yml @@ -25,7 +25,7 @@ jobs: - name: 获取触发版本信息 id: version-info - uses: ./trigger-version + uses: actions/xgj/trigger-version@v1 - name: 显示版本信息 run: | diff --git a/trigger-version/examples/conditional-deployment.yml b/trigger-version/examples/conditional-deployment.yml index f4f8c8b..3a4c2df 100644 --- a/trigger-version/examples/conditional-deployment.yml +++ b/trigger-version/examples/conditional-deployment.yml @@ -25,7 +25,7 @@ jobs: - name: 获取版本信息 id: version-info - uses: ./trigger-version + uses: actions/xgj/trigger-version@v1 - name: 确定部署策略 id: deployment-strategy diff --git a/trigger-version/examples/custom-prefix.yml b/trigger-version/examples/custom-prefix.yml index 9199a2a..ba330cd 100644 --- a/trigger-version/examples/custom-prefix.yml +++ b/trigger-version/examples/custom-prefix.yml @@ -19,7 +19,7 @@ jobs: - name: 获取标准版本信息 id: standard-version - uses: ./trigger-version + uses: actions/xgj/trigger-version@v1 # 使用默认的 'v' 前缀 - name: 显示标准版本信息 @@ -38,7 +38,7 @@ jobs: - name: 获取发布版本信息 id: release-version - uses: ./trigger-version + uses: actions/xgj/trigger-version@v1 with: version-prefix: 'release-' @@ -60,7 +60,7 @@ jobs: - name: 获取热修复版本信息 id: hotfix-version - uses: ./trigger-version + uses: actions/xgj/trigger-version@v1 with: version-prefix: 'hotfix-' @@ -80,7 +80,7 @@ jobs: - name: 获取无前缀版本信息 id: no-prefix-version - uses: ./trigger-version + uses: actions/xgj/trigger-version@v1 with: version-prefix: '' @@ -123,7 +123,7 @@ jobs: - name: 使用动态前缀获取版本信息 id: dynamic-version - uses: ./trigger-version + uses: actions/xgj/trigger-version@v1 with: version-prefix: ${{ env.VERSION_PREFIX }} diff --git a/trigger-version/examples/full-cicd.yml b/trigger-version/examples/full-cicd.yml index 9675e24..3138719 100644 --- a/trigger-version/examples/full-cicd.yml +++ b/trigger-version/examples/full-cicd.yml @@ -36,7 +36,7 @@ jobs: - name: 获取触发版本信息 id: version-info - uses: ./trigger-version + uses: actions/xgj/trigger-version@v1 - name: 确定构建和部署策略 id: build-strategy From 631cc6961fceafec22de4dc262ce8cb282bc1043 Mon Sep 17 00:00:00 2001 From: Lyda <1829913225@qq.com> Date: Thu, 21 Aug 2025 10:13:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20npm-install=20?= =?UTF-8?q?GitHub=20Action=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=94=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=A3=80=E6=B5=8B=E6=AD=A5=E9=AA=A4=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=BC=93=E5=AD=98key=E7=94=9F=E6=88=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=9C=A8=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=94=81=E6=96=87=E4=BB=B6hash=E6=97=B6?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=BB=98=E8=AE=A4=E5=80=BC=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E7=BC=93=E5=AD=98=E7=AE=A1=E7=90=86=E7=9A=84=E5=8F=AF?= =?UTF-8?q?=E9=9D=A0=E6=80=A7=E5=92=8C=E7=81=B5=E6=B4=BB=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- npm-install/action.yml | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/npm-install/action.yml b/npm-install/action.yml index ab416b7..6d43a69 100644 --- a/npm-install/action.yml +++ b/npm-install/action.yml @@ -52,8 +52,8 @@ outputs: runs: using: 'composite' steps: - - name: 生成缓存key - id: cache-key + - name: 检测锁文件 + id: detect-lockfile shell: bash run: | LOCKFILE="${{ inputs.lockfile-name }}" @@ -73,10 +73,29 @@ runs: fi fi - CACHE_KEY="${{ runner.os }}-${{ inputs.cache-prefix }}-$(echo '${{ hashFiles('${LOCKFILE}') }}' | head -c 12)" - echo "key=${CACHE_KEY}" >> $GITHUB_OUTPUT echo "lockfile=${LOCKFILE}" >> $GITHUB_OUTPUT echo "使用锁文件: ${LOCKFILE}" + + - name: 生成缓存key + id: cache-key + shell: bash + env: + LOCKFILE_HASH: ${{ hashFiles(steps.detect-lockfile.outputs.lockfile) }} + run: | + LOCKFILE="${{ steps.detect-lockfile.outputs.lockfile }}" + + # 截取hash的前12位 + if [[ -n "${LOCKFILE_HASH}" && "${LOCKFILE_HASH}" != "" ]]; then + LOCKFILE_HASH_SHORT=$(echo "${LOCKFILE_HASH}" | head -c 12) + else + echo "⚠️ 警告: 无法计算锁文件hash,使用默认值" + LOCKFILE_HASH_SHORT="no-lockfile" + fi + + CACHE_KEY="${{ runner.os }}-${{ inputs.cache-prefix }}-${LOCKFILE_HASH_SHORT}" + echo "key=${CACHE_KEY}" >> $GITHUB_OUTPUT + echo "锁文件: ${LOCKFILE}" + echo "文件hash: ${LOCKFILE_HASH}" echo "缓存key: ${CACHE_KEY}" - name: 拉取缓存依赖