-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary Fixes #1919 ### Time to review: __5 mins__ ## Changes proposed This PR makes two changes: - adds the is-build-published check from navapbc/template-infra#611 - moves build and publish to a more sensible place - adds `build_repository.tf` and adjacent terraform configuration, to bring us in line with the latest infra template code ## Context for reviewers I used this commit to test: https://github.com/HHS/simpler-grants-gov/actions/runs/11059113106/job/30727162490
- Loading branch information
1 parent
9720f2b
commit bea90ec
Showing
13 changed files
with
141 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
# Print the current AWS region | ||
set -euo pipefail | ||
echo -n "$(aws configure list | grep region | awk '{print $2}')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
# Checks if an image tag has already been published to the container repository | ||
# Prints "true" if so, "false" otherwise | ||
|
||
set -euox pipefail | ||
|
||
app_name="$1" | ||
git_ref="$2" | ||
|
||
# Get commit hash | ||
image_tag=$(git rev-parse "${git_ref}") | ||
|
||
# Need to init module when running in CD since GitHub actions does a fresh checkout of repo | ||
terraform -chdir="infra/${app_name}/app-config" init >/dev/null | ||
terraform -chdir="infra/${app_name}/app-config" apply -auto-approve >/dev/null | ||
image_repository_name="$(terraform -chdir="infra/${app_name}/app-config" output -json build_repository_config | jq -r ".name")" | ||
region=$(./bin/current-region) | ||
|
||
result="" | ||
result=$(aws ecr describe-images --repository-name "${image_repository_name}" --image-ids "imageTag=${image_tag}" --region "${region}" 2>/dev/null) || true | ||
if [ -n "${result}" ]; then | ||
echo "true" | ||
else | ||
echo "false" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
data "external" "account_ids_by_name" { | ||
program = ["${path.module}/../../../bin/account-ids-by-name.sh"] | ||
} | ||
|
||
locals { | ||
image_repository_name = "${local.project_name}-${local.app_name}" | ||
image_repository_region = module.project_config.default_region | ||
image_repository_account_name = module.project_config.network_configs[local.shared_network_name].account_name | ||
image_repository_account_id = data.external.account_ids_by_name.result[local.image_repository_account_name] | ||
|
||
build_repository_config = { | ||
name = local.image_repository_name | ||
region = local.image_repository_region | ||
network_name = local.shared_network_name | ||
account_name = local.image_repository_account_name | ||
account_id = local.image_repository_account_id | ||
repository_arn = "arn:aws:ecr:${local.image_repository_region}:${local.image_repository_account_id}:repository/${local.image_repository_name}" | ||
repository_url = "${local.image_repository_account_id}.dkr.ecr.${local.image_repository_region}.amazonaws.com/${local.image_repository_name}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
data "external" "account_ids_by_name" { | ||
program = ["${path.module}/../../../bin/account-ids-by-name.sh"] | ||
} | ||
|
||
locals { | ||
image_repository_name = "${local.project_name}-${local.app_name}" | ||
image_repository_region = module.project_config.default_region | ||
image_repository_account_name = module.project_config.network_configs[local.shared_network_name].account_name | ||
image_repository_account_id = data.external.account_ids_by_name.result[local.image_repository_account_name] | ||
|
||
build_repository_config = { | ||
name = local.image_repository_name | ||
region = local.image_repository_region | ||
network_name = local.shared_network_name | ||
account_name = local.image_repository_account_name | ||
account_id = local.image_repository_account_id | ||
repository_arn = "arn:aws:ecr:${local.image_repository_region}:${local.image_repository_account_id}:repository/${local.image_repository_name}" | ||
repository_url = "${local.image_repository_account_id}.dkr.ecr.${local.image_repository_region}.amazonaws.com/${local.image_repository_name}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
data "external" "account_ids_by_name" { | ||
program = ["${path.module}/../../../bin/account-ids-by-name.sh"] | ||
} | ||
|
||
locals { | ||
image_repository_name = "${local.project_name}-${local.app_name}" | ||
image_repository_region = module.project_config.default_region | ||
image_repository_account_name = module.project_config.network_configs[local.shared_network_name].account_name | ||
image_repository_account_id = data.external.account_ids_by_name.result[local.image_repository_account_name] | ||
|
||
build_repository_config = { | ||
name = local.image_repository_name | ||
region = local.image_repository_region | ||
network_name = local.shared_network_name | ||
account_name = local.image_repository_account_name | ||
account_id = local.image_repository_account_id | ||
repository_arn = "arn:aws:ecr:${local.image_repository_region}:${local.image_repository_account_id}:repository/${local.image_repository_name}" | ||
repository_url = "${local.image_repository_account_id}.dkr.ecr.${local.image_repository_region}.amazonaws.com/${local.image_repository_name}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters