|
5 | 5 | import sys
|
6 | 6 |
|
7 | 7 | REASON = os.environ["REASON"]
|
| 8 | + |
8 | 9 | # the name of the variable that Azure Pipelines uses for the source branch
|
9 | 10 | # depends on the type of run, so need to check both
|
10 | 11 | SOURCE = os.environ.get("OTHER_SOURCE") or os.environ["INDIVIDUAL_SOURCE"]
|
| 12 | + |
11 | 13 | TARGET = os.environ["TARGET"]
|
12 | 14 |
|
13 |
| -# the branches that correspond to environments |
14 |
| -ENV_BRANCHES = ["dev", "test", "prod"] |
| 15 | +# branch to workspace mapping |
| 16 | +WORKSPACES = {"main": "dev", "test": "test", "prod": "default"} |
| 17 | +# workspace to service connection mapping |
| 18 | +SERVICE_CONNECTIONS = {"dev": "Development", "test": "Development", "default": "Production"} |
15 | 19 |
|
16 |
| -if REASON == "PullRequest" and TARGET in ENV_BRANCHES: |
| 20 | +if REASON == "PullRequest" and TARGET in WORKSPACES: |
17 | 21 | # it's a pull request against one of the environment branches, so use the
|
18 | 22 | # target branch
|
19 |
| - environment = TARGET |
20 |
| -elif REASON in ["IndividualCI", "Manual"] and SOURCE in ENV_BRANCHES: |
| 23 | + workspace = WORKSPACES[TARGET] |
| 24 | +elif REASON in ["IndividualCI", "Manual"] and SOURCE in WORKSPACES: |
21 | 25 | # it's being run on one of the environment branches, so use that
|
22 |
| - environment = SOURCE |
| 26 | + workspace = WORKSPACES[SOURCE] |
23 | 27 | else:
|
24 | 28 | # default to running against dev
|
25 |
| - environment = "dev" |
26 |
| - |
27 |
| -# matching logic in ../init.sh |
28 |
| -workspace = "default" if environment == "prod" else environment |
| 29 | + workspace = "dev" |
29 | 30 |
|
30 |
| -service_connection = "Production" if environment == "prod" else "Development" |
| 31 | +service_connection = SERVICE_CONNECTIONS[workspace] |
31 | 32 |
|
32 | 33 | # just for troubleshooting
|
33 | 34 | if TARGET is not None:
|
|
0 commit comments