Skip to content

Commit

Permalink
ci: rename dev branch to main
Browse files Browse the repository at this point in the history
  • Loading branch information
lalver1 committed Jul 9, 2024
1 parent 4b52d3f commit b08096d
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- "**.js"
- "**.py"
pull_request:
branches: [dev, test, prod]
branches: [main, test, prod]
paths:
- "**.js"
- "**.py"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
branches:
- dev
- main
- test
- prod

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeler-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Label dev deploys

on:
pull_request:
branches: [dev]
branches: [main]
types: [opened]
paths:
- ".github/workflows/deploy-*.yml"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeler-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Label docs

on:
pull_request:
branches: [dev]
branches: [main]
types: [opened]
paths:
- 'docs/**'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeler-infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Label infrastructure

on:
pull_request:
branches: [dev]
branches: [main]
types: [opened]
paths:
- 'docs/deployment/**'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ on:
types:
- completed
branches:
- dev
- main
pull_request:
branches:
- dev
- main
paths:
- "docs/**"
- "mkdocs.yml"
- ".github/workflows/mkdocs.yml"
push:
branches:
- dev
- main
paths:
- "docs/**"
- "mkdocs.yml"
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
uses: dawidd6/action-download-artifact@v6
with:
workflow: tests-pytest.yml
branch: dev
branch: main
event: push
name: coverage-report
path: docs/tests/coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: UI & a11y tests
on:
workflow_dispatch:
pull_request:
branches: [dev, test, prod]
branches: [main, test, prod]

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion terraform/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ trigger:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml#pr-triggers
branches:
include:
- dev
- main
- test
- prod
# only run for changes to Terraform files
Expand Down
4 changes: 2 additions & 2 deletions terraform/pipeline/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ steps:
# service connection
environmentServiceNameAzureRM: "${{ parameters.service_connection }}"
# the plan is done as part of the apply (below), so don't bother doing it twice
condition: notIn(variables['Build.SourceBranchName'], 'dev', 'test', 'prod')
condition: notIn(variables['Build.SourceBranchName'], 'main', 'test', 'prod')
- task: TerraformTaskV3@3
displayName: Terraform apply
inputs:
Expand All @@ -60,4 +60,4 @@ steps:
# service connection
environmentServiceNameAzureRM: "${{ parameters.service_connection }}"
# only run on certain branches
condition: in(variables['Build.SourceBranchName'], 'dev', 'test', 'prod')
condition: in(variables['Build.SourceBranchName'], 'main', 'test', 'prod')
17 changes: 10 additions & 7 deletions terraform/pipeline/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,32 @@
import sys

REASON = os.environ["REASON"]

# the name of the variable that Azure Pipelines uses for the source branch
# depends on the type of run, so need to check both
SOURCE = os.environ.get("OTHER_SOURCE") or os.environ["INDIVIDUAL_SOURCE"]

TARGET = os.environ["TARGET"]

# the branches that correspond to environments
ENV_BRANCHES = ["dev", "test", "prod"]
# branch to workspace/environment mapping
ENV_BRANCHES = {"main": "dev", "test": "test", "prod": "prod"}

if REASON == "PullRequest" and TARGET in ENV_BRANCHES:
# it's a pull request against one of the environment branches, so use the
# target branch
environment = TARGET
workspace = ENV_BRANCHES[TARGET]
elif REASON in ["IndividualCI", "Manual"] and SOURCE in ENV_BRANCHES:
# it's being run on one of the environment branches, so use that
environment = SOURCE
workspace = ENV_BRANCHES[SOURCE]
else:
# default to running against dev
environment = "dev"
workspace = "dev"

# matching logic in ../init.sh
workspace = "default" if environment == "prod" else environment
# workspace to service connection mapping
service_connections = {"dev": "Development", "test": "Development", "prod": "Production"}

service_connection = "Production" if environment == "prod" else "Development"
service_connection = service_connections[workspace]

# just for troubleshooting
if TARGET is not None:
Expand Down

0 comments on commit b08096d

Please sign in to comment.