如何在手动运行Git操作时指定特定的提交?

5

我该如何创建一个只能手动启动的工作流,同时需要指定它将使用哪个特定的提交?

2个回答

5
你可以手动运行工作流程, 只要它被配置为在workflow_dispatch事件上运行。
添加inputs来定义你的参数。
on:
  workflow_dispatch:
    inputs:
      myCommit:
        description: 'Commit SHA1'
        required: true
        default: 'undefined'
        type: string

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Do something
        run: your_command ${{ inputs.myCommit }}
  ...

5

以下是一个检出特定提交版本进行构建的示例:

on:
  workflow_dispatch:
    inputs:
      refToBuild:
        description: 'Branch, tag or commit SHA1 to build'
        required: true
        type: string

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ inputs.refToBuild }}

      - name: Build
        run: <command for build>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接