1

I want to check inside a github action whether a branch (e.g. "main") exists. I tried

    - name: get Branch
      run: |
        export BRANCHES=git branch -r
        echo "${{ contains($BRANCHES, 'main') }}"

But this is apparently a syntax error.

Can somebody tell me how to do this properly?

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • You can only use `${{ }}` expressions with GitHub Actions variables. Either save the result of the `git branch` command to the step output and reference it in another step or use the built-in functionality of your shell (e.g. for bash: https://stackoverflow.com/questions/229551/how-to-check-if-a-string-contains-a-substring-in-bash). – riQQ Feb 01 '22 at 21:14
  • This gist can be useful as well if you want to use bash: https://gist.github.com/iridiumcao/714d3d0a9137ce614c26e4e10d185291 – GuiFalourd Feb 01 '22 at 21:22

0 Answers0