Skip to content

Commit bdfd453

Browse files
committed
test jobs.<job_id>.steps.if
1 parent 3bcce81 commit bdfd453

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

.github/workflows/publish.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
tags:
88
- "v*"
99

10+
# workflow_dispatch 是 GitHub 的手动触发 CI 机制,可以与 inputs 预定义的变量一起使用,对 push 触发的 CI 不生效。
1011
workflow_dispatch:
1112
inputs:
1213
docker:
@@ -100,14 +101,21 @@ jobs:
100101

101102
deploy-to-deno:
102103
needs: [upload-art]
103-
if: ${{ inputs.deno || github.event_name == 'push' }}
104+
# 参考链接:https://docs.github.com/zh/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context
105+
# 需求是不让下面的 release-docker 任务在 push 触发的 CI 中执行。
106+
# 在 jobs.<job_id>.if 中没办法使用 env 环境变量,因此没办法根据变量的值处理 push 触发的 CI 是否进行这一步。jobs.<job_id>.steps.if 是可以使用 env 的,因此只能在 steps 里面处理了。
107+
if: ${{ inputs.deno || ( github.event_name == 'push') }}
104108
runs-on: ubuntu-latest
105109
permissions:
106110
id-token: write
107111
contents: read
108112

113+
env:
114+
DEPLOY_DENO_PUSH: false
115+
109116
steps:
110117
- uses: actions/download-artifact@v4
118+
if: ${{ DEPLOY_DENO_PUSH }}
111119
with:
112120
name: deno.js
113121
- name: Upload to Deno Deploy

0 commit comments

Comments
 (0)