我可以根据提交消息过滤GitHub操作步骤吗? [英] Can I filter a GitHub action step based on the commit message?
问题描述
我最近在GitHub动作中添加了静态分析步骤.但是,它有些昂贵,因此我试图减少执行此步骤的次数.我已经添加了一个适当的筛选器,以便它只能在一个OS上运行,并且只能在我的功能"分支上运行.但是,我还要过滤掉提交消息中包括"WIP"的所有签入.(从理论上讲,直到不再是进行中的工作",再进行完整的分析是没有意义的.)
I've recently added a static analysis step to my GitHub actions. However, it is somewhat expensive so I'm trying to reduce the number of times that this step is run. I've already added an appropriate filter so that it only runs on one OS and so that it only runs on my "feature" branches. However, I would like to also filter out any checkins that include "WIP" in their commit message. (The theory being that there is no point in performing the full analysis until it is no longer a "Work In Progress".)
我在文档中进行了搜索,希望找到可以用作 github
上下文对象一部分的对象,但无济于事.
I've searched through the docs, expecting I would find an object I could use as part of the github
context object, but to no avail.
关于如何实现此目标的任何想法?
Any ideas on how I can accomplish this goal?
如果您想确切地了解我在做什么,则Yaml的操作如下.我希望可以对 Static Analysis
项上的 if
语句进行一些更改,以实现我的目标.
If you want to see exactly what I'm doing, the action Yaml is as follows. I'm hoping to find some change I can make to the if
statement on the Static Analysis
item that would accomplish my goal.
name: On Push
on: [push]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- name: Build
run: |
./configure
make -j 4
- name: Run tests
run: |
make -j 4 check
- name: Static Analysis
if: runner.os == 'macOS' && startsWith(github.ref, 'refs/heads/feature/')
run: |
make analyze
推荐答案
您可以在推送有效载荷.
在执行分析的步骤中添加以下内容:
Add the following to the step that does the analysis:
if: !startsWith(github.event.head_commit.message, 'WIP')
这篇关于我可以根据提交消息过滤GitHub操作步骤吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!