2

I have two workflows: CI (for continuous integration) and CD (for continuous delivery). My goal is if someone makes a changes to branches other than master branches, I want to execute CD as well on that branch

But its taking ref as master in CD

ci.yaml

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

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. How to make workflow_run to pick up branch changes

asked Apr 17, 2021 at 12:37
1
  • I don't know if it's possible to do it through a workflow_run event, but I believe it would be possible through a repository_dispatch event, as you could send the branch reference in the dispatch request on the CI workflow to be used on the second workflow (CD). Commented Apr 17, 2021 at 13:07

1 Answer 1

1

If I correctly understood what you are looking for, i.e. having the name of the original branch whose CI workflow triggered CD, changing

github.ref

with:

github.event.workflow_run.head_branch

will solve the problem

answered Apr 17, 2021 at 13:43
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.