从很长一段时间以来,我一直在从事GitHub Actions的工作,并且我们有一个指定的工作流程。工作流程已使用yaml编写。
我正在尝试为if
设置一些github.ref
条件,并且在运行时跳过了yaml块。
这意味着-如果对X分支提出了pull请求-该代码块应运行。
类似这样的东西:
- name: Branch name check - Running only for DEV branch..
if: ${{contains(github.ref, 'DEV*')}}
uses: mathrix-education/sonar-scanner@master
with:
version: 4.2.0.1873 # required
typescript: false
scan: true
有人可以帮我吗?
答案 0 :(得分:0)
使用以下命令检查拉取请求的基础:
if: ${{contains(github.base_ref, 'DEV')}}
github.ref
将包含类似refs/pull/1/merge
的请求请求。
答案 1 :(得分:0)
在构建github工作流程时,我们遇到了类似的事情。我们正在工作的条件:
经过研究,以下是我们提出的内容。我发现Github Actions非常灵活,具有许多Gitlab和Bitbucket没有的选项。但这也是不利的一面,有时会使理解变得更加复杂。
---
name: workflow
on:
push:
branches: [develop]
pull_request:
branches: [develop, master]
types: [closed]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v1
- name: step 1
if: github.ref == 'refs/heads/develop' || github.event.pull_request.base.ref == 'develop'
run: echo "Hello develop"
- name: step 2
if: github.event.pull_request.base.ref == 'master'
run: echo "Hello master"