在GitHub存储库中,我有两个单独的GitHub Actions工作流程:
github/workflows/pr.yml
仅用于构建和测试
name: Pull request workflow
on: pull_request
和github/workflows/push.yml
进行构建,测试和部署
name: Push workflow
on: push
创建请求请求会触发这两个工作流程。
是否无法分开这些?或者我在这里想念什么?
答案 0 :(得分:3)
如果仅部署某些分支,请按照以下方式限制Push workflow
:
name: Push workflow
on:
push:
branches:
- master
另一种选择是排除分支
on:
push:
# Sequence of patterns matched against refs/heads
branches-ignore:
# Push events to branches matching refs/heads/mona/octocat
- 'mona/octocat'
# Push events to branches matching refs/heads/releases/beta/3-alpha
- 'releases/**-alpha'
答案 1 :(得分:0)
答案 2 :(得分:0)
您可以在工作中使用这些行来避免内部拉取请求(也会触发推送)触发您的工作流,同时允许外部拉取请求触发您的工作流。
# a push event from the origin repo, or a PR from external repo
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'your/full_repo_name' }}
参考: