froggomad
froggomad

Reputation: 1915

Set list of branches matching pattern as output variable in GitHub Actions (yml)

I'm trying to create a GitHub action that will output a list of feature/ branches for use in another workflow. My output for this step is always an empty string.

I run this step after running actions/checkout, configuring the git environment, fetching, and traversing to the repo's directory:

echo ::set-output name=branches::$(git branch --list | grep feature/)

However, running this in terminal with the same repo checked out on my machine, I get a list of feature branches.

Upvotes: 0

Views: 1006

Answers (1)

Grzegorz Krukowski
Grzegorz Krukowski

Reputation: 19802

Using git branch --list will show you just local branches that you checkout locally.

In GitHub Action checkout action, you are usually checking out just single branch.

To get all branches despite of the checkout methods, you have to use: git branch -r and grep that one.

Upvotes: 1

Related Questions