Skip to content

Commit 5727d39

Browse files
Drop workflow permissions, apply reusable workflow to production
1 parent c5694c1 commit 5727d39

File tree

2 files changed

+6
-61
lines changed

2 files changed

+6
-61
lines changed

.github/workflows/deploy-sandbox.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ on:
44
pull_request:
55
branches: [ "**" ]
66

7-
permissions:
8-
id-token: write
9-
contents: read
10-
117
jobs:
128
build-matrix:
139
permissions:

.github/workflows/release-published.yml

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,13 @@ on:
55

66
name: Deploy to Production
77

8-
permissions:
9-
contents: read
10-
11-
128
jobs:
139
build-matrix:
14-
runs-on: ubuntu-latest
15-
outputs:
16-
matrix: ${{ steps.build-matrix.outputs.matrix }}
17-
steps:
18-
- uses: actions/checkout@09d2acae674a48949e3602304ab46fd20ae0c42f
19-
- name: Build Environment Matrix
20-
id: build-matrix
21-
shell: python
22-
env:
23-
PLATFORM_ENVIRONMENT: "production"
24-
run: |
25-
from pathlib import Path
26-
import os
27-
import json
28-
29-
def discover_environments(platform_path: Path = Path("platform")) -> list[Path]:
30-
return [d for d in platform_path.iterdir() if d.is_dir()]
31-
32-
def discover_regions(environment_path: Path) -> list[Path]:
33-
return [d for d in environment_path.iterdir() if d.is_dir()]
34-
35-
def discover_instances(region_path: Path) -> list[Path]:
36-
return [d for d in region_path.iterdir() if d.is_dir()]
37-
38-
try:
39-
ENVIRONMENT = os.environ['PLATFORM_ENVIRONMENT']
40-
except KeyError as ke:
41-
raise ValueError("Environment variable named PLATFORM_ENVIRONMENT was not found. This variable must be supplied so that a matrix of environments can be built!")
42-
43-
if len(ENVIRONMENT) == 0:
44-
raise ValueError("Environment variable PLATFORM_ENVIRONMENT was empty. This variable must be supplied so that a matrix of environments can be built!")
45-
46-
all_environments = discover_environments()
47-
matrix = {"terragrunt_environment": []}
48-
try:
49-
selected_environment = list(filter(lambda x: x.name == ENVIRONMENT, all_environments))[0]
50-
except Exception:
51-
raise ValueError(f"Expected environment '{ENVIRONMENT}' not found in {all_environments}")
52-
53-
regions = discover_regions(environment_path=selected_environment)
54-
55-
for region_path in regions:
56-
region_instances = discover_instances(region_path=region_path)
57-
for instance in region_instances:
58-
matrix["terragrunt_environment"].append({"environment": selected_environment.name, "region": region_path.name, "instance": instance.name})
59-
60-
print("Generated the following environment matrix:")
61-
print(json.dumps(matrix, indent=4))
62-
63-
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
64-
f.write(f"matrix={json.dumps(matrix, separators=(',', ':'))}")
10+
permissions:
11+
contents: read
12+
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-github-matrix-tg.yml@0.1.3
13+
with:
14+
platform_environment: production
6515

6616
call-terragrunt-deploy:
6717
needs: build-matrix
@@ -72,12 +22,11 @@ jobs:
7222
fail-fast: false
7323
matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }}
7424

75-
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-terragrunt-deploy.yml@v0.1.0
25+
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-terragrunt-deploy.yml@0.1.3
7626
with:
7727
tf_version: '1.5.5'
7828
tg_version: '0.54.11'
7929
environment: ${{ matrix.terragrunt_environment.environment }}
8030
region: ${{ matrix.terragrunt_environment.region }}
8131
env_id: ${{ matrix.terragrunt_environment.instance }}
82-
8332
secrets: inherit

0 commit comments

Comments
 (0)