Skip to content

Commit

Permalink
Fix: GitHub CI workflow selects dev when building prod branch (#5428)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes-ucsc committed Feb 7, 2025
1 parent 64b1419 commit 118ade8
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions scripts/check_branch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import sys
from typing import (
Expand All @@ -9,11 +10,16 @@
from azul import (
config,
)
from azul.logging import (
configure_script_logging,
)

"""
Ensure that the currently checked out branch matches the selected deployment
"""

log = logging.getLogger(__name__)


def default_deployment(branch: str | None) -> str | None:
deployments = config.shared_deployments_for_branch(branch)
Expand Down Expand Up @@ -83,9 +89,17 @@ def target_branch() -> str | None:
except KeyError:
pass
else:
return branch
if branch:
log.info('Target branch is %r as defined in %r', branch, variable)
return branch
repo = git.Repo(config.project_root)
return None if repo.head.is_detached else repo.head.reference.name
if repo.head.is_detached:
branch = None
log.info('Target branch is %r because HEAD is detached', branch)
else:
branch = repo.head.reference.name
log.info('Target branch is %r because it is checked out', branch)
return branch


def main(argv):
Expand All @@ -109,4 +123,5 @@ def main(argv):


if __name__ == '__main__':
configure_script_logging(log)
main(sys.argv[1:])

0 comments on commit 118ade8

Please sign in to comment.