Skip to content

Commit 5b1adc5

Browse files
authored
Variable parameterization (#32)
* Parameterization to prepare for deployment to prod (#29) * Prepare for prod build--workflow definition for prod branch (#30) * Parameterization to prepare for deployment to prod * Prepare prod image build * Fix variable substitution mistake (#31) * Parameterization to prepare for deployment to prod * Prepare prod image build * Update build.yaml * Update build.yaml * Update build.yaml * Update build.yaml * Update build.yaml * Update build.yaml
1 parent e8ba9c8 commit 5b1adc5

File tree

2 files changed

+39
-30
lines changed

2 files changed

+39
-30
lines changed

.github/workflows/build.yaml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- dev
66
- stage
7+
- prod
78

89
workflow_dispatch:
910
inputs:
@@ -14,7 +15,7 @@ on:
1415
options:
1516
- ''
1617
- '--no-cache'
17-
18+
1819
jobs:
1920
build:
2021
runs-on: ubuntu-latest
@@ -32,30 +33,27 @@ jobs:
3233
username: ${{ vars.DOCKERHUB_USERNAME }}
3334
password: ${{ secrets.DOCKERHUB_TOKEN }}
3435

35-
# - name: Get last tag
36-
# run: echo "TAG_LAST=$(git describe --tags --abbrev=0 --always)" >> $GITHUB_ENV
37-
38-
# - name: "Build Changelog"
39-
# id: build_changelog
40-
# uses: mikepenz/release-changelog-builder-action@v5
41-
# with:
42-
# toTag: "${{ github.ref }}"
43-
# mode: "HYBRID"
44-
# outputFile: "CHANGELOG.md"
45-
46-
# - name: Print CHANGELOG.md
47-
# run: cat CHANGELOG.md
48-
4936
- name: Set up Docker Buildx
5037
uses: docker/setup-buildx-action@v3
38+
39+
# see tdei_uw.env for why
40+
- name: Override ENV_NAME_PARAM for prod deployments
41+
if: github.ref_name == 'prod'
42+
run: echo "ENV_NAME_PARAM=" >> "$GITHUB_ENV"
43+
- name: Override ENV_NAME_PARAM for dev or stage deployments
44+
if: github.ref_name != 'prod'
45+
env:
46+
ENV: ${{ vars.ENV }}
47+
run: echo "ENV_NAME_PARAM=-${ENV}" >> "$GITHUB_ENV"
5148

5249
- name: Build and push
53-
run: |
50+
run: |
5451
docker compose -f docker-compose.build.yml --env-file tdei_uw.env build --build-arg CODE_VERSION=${CODE_VERSION} ${{github.event.inputs.build_flag}}
5552
docker compose -f docker-compose.build.yml --env-file tdei_uw.env push
5653
env:
5754
ENV: ${{ vars.ENV }}
5855
CODE_VERSION: ${{ github.sha }}
56+
ENV_NAME_PARAM: ${{ env.ENV_NAME_PARAM }}
5957

6058
# hosts
6159
WS_DOCKER_REGISTRY: ${{ vars.WS_DOCKER_REGISTRY }}
@@ -74,6 +72,7 @@ jobs:
7472
env:
7573
ENV: ${{ vars.ENV }}
7674
CODE_VERSION: ${{ github.sha }}
75+
ENV_NAME_PARAM: ${{ env.ENV_NAME_PARAM }}
7776

7877
# machine to deploy to
7978
AZURE_DOCKER_HOST_IP: ${{ vars.AZURE_DOCKER_HOST_IP }}

tdei_uw.env

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#
2+
# Resources for dev and stage are often db-dev, db-stage, while prod resources
3+
# are just "db", not "db-prod". This variable allows us to construct the
4+
# environment-prefixed variable values without putting the "-" in ENV which is
5+
# used elsewhere.
6+
#
7+
# **This variable should therefore be set to empty string on prod **
8+
#
9+
ENV_NAME_PARAM=-${ENV}
10+
111
###############################################################################
212
# Docker
313
###############################################################################
@@ -18,18 +28,18 @@ WS_PLATFORM_PRIVACY_POLICY=https://sidewalks.washington.edu/privacy
1828
# Web
1929
###############################################################################
2030

21-
WS_TDEI_FRONTEND_URL=https://portal-${ENV}.tdei.us/
22-
WS_TDEI_BACKEND_URL=https://portal-api-${ENV}.tdei.us/api/v1/
23-
WS_TDEI_API_URL=https://api-${ENV}.tdei.us/api/v1/
24-
WS_TDEI_OIDC_URL=https://account-{$ENV}.tdei.us/
31+
WS_TDEI_FRONTEND_URL=https://portal${ENV_NAME_PARAM}.tdei.us/
32+
WS_TDEI_BACKEND_URL=https://portal-api${ENV_NAME_PARAM}.tdei.us/api/v1/
33+
WS_TDEI_API_URL=https://api${ENV_NAME_PARAM}.tdei.us/api/v1/
34+
WS_TDEI_OIDC_URL=https://account${ENV_NAME_PARAM}.tdei.us/
2535
WS_TDEI_OIDC_REALM=tdei
2636

27-
WS_FRONTEND_HOST=workspaces-${ENV}.sidewalks.washington.edu
28-
WS_API_HOST=api.workspaces-${ENV}.sidewalks.washington.edu
29-
WS_RAPID_HOST=rapid.workspaces-${ENV}.sidewalks.washington.edu
30-
WS_PATHWAYS_EDITOR_HOST=pathways.workspaces-${ENV}.sidewalks.washington.edu
31-
WS_OSM_HOST=osm.workspaces-${ENV}.sidewalks.washington.edu
32-
WS_TASKS_HOST=tasks.workspaces-${ENV}.sidewalks.washington.edu
37+
WS_FRONTEND_HOST=workspaces${ENV_NAME_PARAM}.sidewalks.washington.edu
38+
WS_API_HOST=api.workspaces${ENV_NAME_PARAM}.sidewalks.washington.edu
39+
WS_RAPID_HOST=rapid.workspaces${ENV_NAME_PARAM}.sidewalks.washington.edu
40+
WS_PATHWAYS_EDITOR_HOST=pathways.workspaces${ENV_NAME_PARAM}.sidewalks.washington.edu
41+
WS_OSM_HOST=osm.workspaces${ENV_NAME_PARAM}.sidewalks.washington.edu
42+
WS_TASKS_HOST=tasks.workspaces${ENV_NAME_PARAM}.sidewalks.washington.edu
3343

3444
WS_DEV_PORT=3000
3545

@@ -56,15 +66,15 @@ WS_API_DB_NAME=workspaces
5666

5767
WS_OSM_DB_HOST=${WS_POSM_DB_HOST}
5868
WS_OSM_DB_PORT=5432
59-
WS_OSM_DB_USER=workspaces-osm-${ENV}
69+
WS_OSM_DB_USER=workspaces-osm${ENV_NAME_PARAM}
6070
WS_OSM_DB_PASS=${WS_OSM_DB_PASS}
61-
WS_OSM_DB_NAME=workspaces-osm-${ENV}
71+
WS_OSM_DB_NAME=workspaces-osm${ENV_NAME_PARAM}
6272

6373
WS_TASKS_DB_HOST=${WS_POSM_DB_HOST}
6474
WS_TASKS_DB_PORT=5432
65-
WS_TASKS_DB_USER=workspaces-tasks-${ENV}
75+
WS_TASKS_DB_USER=workspaces-tasks${ENV_NAME_PARAM}
6676
WS_TASKS_DB_PASS=${WS_TASKS_DB_PASS}
67-
WS_TASKS_DB_NAME=workspaces-tasks-${ENV}
77+
WS_TASKS_DB_NAME=workspaces-tasks${ENV_NAME_PARAM}
6878

6979
###############################################################################
7080
# Mail

0 commit comments

Comments
 (0)