GitHub动作触发新的Pull Requests的构建 [英] GitHub actions to trigger build on new Pull Requests
问题描述
我有以下工作流程来触发GitHub项目上的CMake构建:
I have the following workflow to trigger CMake builds on my GitHub project:
name: C/C++ CI
on:
push:
branches: [ master, develop ]
pull_request:
types: [ opened, edited, reopened, review_requested ]
branches: [ master, develop ]
jobs:
build:
runs-on: ubuntu-18.04
steps:
- name: Install deps
run: sudo apt-get update; sudo apt-get install python3-distutils libfastjson-dev libcurl4-gnutls-dev libssl-dev -y
- uses: actions/checkout@v2
- name: Run CMake
run: mkdir build; cd build; cmake .. -DCMAKE_INSTALL_PREFIX=/home/runner/work/access/build/ext_install;
- name: Run make
run: cd build; make -j8
我希望它可以触发基于新的Pull Request的构建,并将构建状态作为批准合并的条件.
I expected it to trigger builds on new Pull Requests and have the build status as a condition to approve the merging.
但是我发现要达到这样的结果有点挑战.关于GitHub Actions,我有点像新手.
However I'm finding it a bit challenging to achieve such results. I'm sort of a newbie when it comes to GitHub Actions.
推荐答案
我可以结合使用github操作和github保护的分支设置来完成您的方案.
I'm able to accomplish your scenario with a combination of github actions and github protected branch settings.
您已经正确设置了github操作,以在具有目标分支(主分支或开发分支)的Pull Request上运行.
You've got your github actions setup correctly to run on a Pull Request with a destination branch: master or develop.
现在,您必须配置您的存储库以防止在CI失败时合并PR:
Now you have to configure your repo to prevent merging a PR if the CI fails:
在您的Github存储库上,转到 Settings =>分支=>添加规则=>将分支名称模式设置为master =>启用合并之前需要状态检查通过" =>上周对该存储库进行的状态检查选择了您要强制执行的CI构建
On your Github Repo, go to Settings => Branches => Add a rule => Set branch name pattern to master => Enable 'Require status checks to pass before merging' => Status checks found in the last week for this repository pick the CI build you want to enforce
这篇关于GitHub动作触发新的Pull Requests的构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!