简体   繁体   English

Github 操作:在 workflow_run 上读取分支更改

[英]Github actions: read branch changes on workflow_run

I have two workflows: CI (for continuous integration) and CD (for continuous delivery).我有两个工作流程:CI(用于持续集成)和 CD(用于持续交付)。 My goal is if someone makes a changes to branches other than master branches, I want to execute CD as well on that branch我的目标是如果有人对主分支以外的分支进行更改,我也想在该分支上执行 CD

But its taking ref as master in CD但它以 ref 作为 CD 中的主控

ci.yaml ci.yaml

name: CI

on:
  push:
    branches:
      - master
      - test
  pull_request:
    types: [opened, synchronize, ready_for_review]
    branches:
      - master

cd.yaml cd.yaml

name: CD

on:
  workflow_run:
    workflows: ["CI"]
    types: 
      - completed

jobs:
  deployment:
    name: CD
    runs-on: ubuntu-latest  
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.ref }}  

When I make changes to test branch, CD is not picking up the changes in test branch, instead working with defaul master config.当我对测试分支进行更改时,CD 不会获取测试分支中的更改,而是使用默认主配置。 How to make workflow_run to pick up branch changes如何使 workflow_run 获取分支更改

If I correctly understood what you are looking for, ie having the name of the original branch whose CI workflow triggered CD, changing如果我正确理解了您要查找的内容,即具有 CI 工作流触发 CD 的原始分支的名称,则更改

github.ref

with:和:

github.event.workflow_run.head_branch

will solve the problem会解决问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在推送到另一个分支时触发 Github Actions 工作流? - How to trigger a Github Actions workflow on push to another branch? 从 GitHub 操作中运行的当前工作流中获取最新成功运行的工作流的提交 hash? - Get the commit hash of the latest successful workflow run from within the current workflow run in GitHub Actions? Github 操作:寻找对拉取请求事件和工作流调度事件均可见的分支级别属性 - Github actions: Seeking a branch level property that is visible to both pull request events and workflow dispatch events Github 动作,在分支上调度操作 - Github actions, schedule operation on branch GitHub 动作,检测子模块的变化 - GitHub Actions, detect changes in submodule 在 bash 中检查 git 中的任何更改时,if-then-else 条件的预期行为与在 github 操作工作流中编写时相反 - Expected behaviour of if-then-else condition in bash while checking for any changes in git is opposite when written in a github actions workflow 重新定位远程分支的git / github工作流程 - git/github workflow on rebasing remote branch 将更改推送到github中的另一个分支 - Push changes to another branch in github GitHub 操作 GIT_BRANCH 环境变量 - GitHub Actions GIT_BRANCH environment variable Github 操作仅在默认分支上触发 - Github Actions only triggers on default branch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM