Skip to content

Commit 33a7a95

Browse files
committed
Fix: GitHub CI workflow selects dev when building prod branch (#5428)
1 parent 1f1f59e commit 33a7a95

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

scripts/check_branch.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import os
23
import sys
34
from typing import (
@@ -9,11 +10,16 @@
910
from azul import (
1011
config,
1112
)
13+
from azul.logging import (
14+
configure_script_logging,
15+
)
1216

1317
"""
1418
Ensure that the currently checked out branch matches the selected deployment
1519
"""
1620

21+
log = logging.getLogger(__name__)
22+
1723

1824
def default_deployment(branch: str | None) -> str | None:
1925
deployments = config.shared_deployments_for_branch(branch)
@@ -83,9 +89,17 @@ def target_branch() -> str | None:
8389
except KeyError:
8490
pass
8591
else:
86-
return branch
92+
if branch:
93+
log.info('Target branch is %r as defined in %r', branch, variable)
94+
return branch
8795
repo = git.Repo(config.project_root)
88-
return None if repo.head.is_detached else repo.head.reference.name
96+
if repo.head.is_detached:
97+
branch = None
98+
log.info('Target branch is %r because HEAD is detached', branch)
99+
else:
100+
branch = repo.head.reference.name
101+
log.info('Target branch is %r because it is checked out', branch)
102+
return branch
89103

90104

91105
def main(argv):
@@ -109,4 +123,5 @@ def main(argv):
109123

110124

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

0 commit comments

Comments
 (0)