Previously, the github-actions config was using the GITHUB_HEAD_REF
environment variable to determine branch name. Unfortunately,
this variable is only set for pull requests causing the
associated docker build step to fail for when the "main" branch
tries to build a docker image.
The solution is to use bash parameter expansion to both:
1) Default to using GITHUB_HEAD_REF if it exists otherwise use GITHUB_REF
2) Use GITHUB_REF after trimming with parameter expansion since
it takes on values like refs/heads/feature-branch-1 and we
only want the feature-branch-1 part of the string.
This PR is meant to resolve docker images not building after merging a PR into
main
: https://github.com/AllenInstitute/ecephys_etl_pipelines/runs/2747687614 (example failure)Previously, the github-actions config was using the
GITHUB_HEAD_REF
environment variable to determine branch name. Unfortunately, this variable is only set for pull requests causing the associated docker build step to fail for when the "main" branch tries to build a docker image.The solution is to use bash parameter expansion to both: 1) Default to using
GITHUB_HEAD_REF
if it exists otherwise useGITHUB_REF
2) UseGITHUB_REF
after trimming with parameter expansion since it takes on values likerefs/heads/feature-branch-1
and we only want thefeature-branch-1
part of the string.Further reading: https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables https://wiki.bash-hackers.org/syntax/pe