默认情况只有pushpull request动作才会触发构建

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
1
2
3
4
5

最简单的做法,添加workflow_dispatch动作

on:
  workflow_dispatch:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
1
2
3
4
5
6

这样在actions页面可以看到执行构建的按钮,选择分支后可以执行手动构建。 image.png

on:
  workflow_dispatch:
    inputs:
      name:
        description: 'Person to greet'
        required: true
        default: 'Mona the Octocat'
      home:
        description: 'location'
        required: false

jobs:
  say_hello:
    runs-on: ubuntu-latest
    steps:
    - run: |
        echo "Hello ${{ github.event.inputs.name }}!"
        echo "- in ${{ github.event.inputs.home }}!"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

关于手动触发还支持自定义输入文本,也就是输入文本当成传入的参数,用在后续的构建命令中 image.png

# 参考

https://p3terx.com/archives/github-actions-manual-trigger.html

https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#manual-events

上次更新: 10/29/2020, 7:06:15 AM