'Github Actions - multiple repository checkout - try same branch name or fallback to main?

I cannot find anything which could help with the issue I am trying to solve. I am setting up a multi-repository project at the moment (multiple backend services, some frontend etc).

To get E2E/integration tests running, I want to set up the step which will run after the base repo (the one with an MR) verification steps, which will trigger the E2E job (can be a separate repository) which will checkout either the same branch if exists in other repos (like I am developing XXX-1234 ticket, so I will create same branches in multiple repositories) or will fallback to main (if the current change does not touch some services).

Example:

  1. We have repoA, repoB, repoC and repoE2E.
  2. I create XXX-1234 branches in repoA and repoB.
  3. When the PRs in repoA and repoB are created and pipelines pass, the action(s) in repoE2E
  4. The action in repoE2E checks out XXX-1234 from repoA and repoB, but as this branch name does not exist in repoC, it will checkout main instead.

It looks like not a unique problem, but I couldn't manage to find anything related to similar issues.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source