如何在推送事件中跳过 GitHub Actions 作业? [英] How to skip GitHub Actions job on push event?
问题描述
使用 Travis CI,我们可以通过向提交添加后缀来跳过特定提交的构建.这在 Travis CI 中有描述.当我只编辑与代码无关的 README.md
并且不需要触发飞行前构建时,我发现此功能很实用.
With Travis CI, we can skip the build for a particular commit with adding a suffix to a commit. This is described at Travis CI. I find this feature practical when I only edit README.md
which is not code-related and the pre-flight build doesn't need to be triggered.
[skip ci]
如何使用 GitHub Actions 跳过触发 on: push
事件的作业?
How do I skip the jobs trigged on: push
events using GitHub Actions?
name: Maven Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check-out project
uses: actions/checkout@v1
- name: Set up JDK 11.0.3
uses: actions/setup-java@v1
with:
java-version: 11.0.3
- name: Build with Maven
run: mvn -B package --file pom.xml
答案总结:
非常感谢所有提供各种方法来实现它的回答者.我敢打赌,对于问题的根源和 CI 方法,每个人都需要一些不同的东西.以下是为快速导航列出的答案:
Big thanks to all the answerers providing various ways to achieve it. I bet everybody would need something a little bit different regarding to the origin of their problem and the CI approach. Here are the answers listed for a quick navigation:
- 在
readme.md
文件中跳过 CI:https://stackoverflow.com/a/61876395/3764965 - 在
[skip ci]
上跳过 CI 作为新的 GitHub 功能:- https://stackoverflow.com/a/66156840/3764965(在此回答)
- https://stackoverflow.com/a/66114678/3764965(在另一个问题中回答)
- Skip CI on
readme.md
file: https://stackoverflow.com/a/61876395/3764965 - Skip CI on
[skip ci]
as a new GitHub feature:- https://stackoverflow.com/a/66156840/3764965 (answer here)
- https://stackoverflow.com/a/66114678/3764965 (answer in another question)
所有答案都值得点赞!如果你喜欢我的问题,你应该双重喜欢答案.
All the answers deserve upvote! If you like my question, you should double-like the answers.
推荐答案
另外,对于您希望在所有推送中忽略的文件和目录 你可以自己配置工作流:
Also, for files and directories you want ignored on all pushes you can configure the workflow itself:
on: push: paths-ignore: - 'README.md'
这篇关于如何在推送事件中跳过 GitHub Actions 作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!