ste*_*238 30 yaml github github-actions
在 GitHub 中,我有一个名为 的拉取请求[WIP] Dev-123 Sample Pull Request。
我想在 GitHub Actions yaml 管道中获取此标题。
在GitHub Docs Context中,我似乎找不到需要引用的对象。
ste*_*238 41
拉取请求的标题可以通过以下方式访问github.event.pull_request.title
使用它的工作流程是:
on:
push:
pull_request:
types: [opened, synchronize]
print_title_of_pr:
runs-on: ubuntu-20.04
steps:
- name : Print Title of PR
run: echo The Title of your PR is ${{ github.event.pull_request.title }}
Run Code Online (Sandbox Code Playgroud)
Yar*_*tal 11
上面接受的答案使用起来不安全,并且会使工作流程遭受关键的命令注入攻击。用户控制的输入在使用前应进行消毒。您可以通过添加中间环境变量来缓解这种情况
参考: https ://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
on:
push:
pull_request:
types: [opened, synchronize]
print_title_of_pr:
runs-on: ubuntu-20.04
steps:
- name : Print Title of PR
env:
TITLE: ${{ github.event.pull_request.title }}
run: echo The Title of your PR is $TITLE
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23441 次 |
| 最近记录: |