mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Merge pull request #702 from Hestia-Homes/feature/deploy_safely
Feature/deploy safely
This commit is contained in:
commit
d4064da365
4 changed files with 48 additions and 10 deletions
2
.github/workflows/_build_image.yml
vendored
2
.github/workflows/_build_image.yml
vendored
|
|
@ -104,4 +104,4 @@ jobs:
|
||||||
--image-ids imageTag=${GITHUB_SHA} \
|
--image-ids imageTag=${GITHUB_SHA} \
|
||||||
--query 'imageDetails[0].imageDigest' \
|
--query 'imageDetails[0].imageDigest' \
|
||||||
--output text)
|
--output text)
|
||||||
echo "image_digest=$DIGEST" >> "$GITHUB_OUTPUT"
|
echo "image_digest=$DIGEST" >> "$GITHUB_OUTPUT"
|
||||||
18
.github/workflows/_deploy_lambda.yml
vendored
18
.github/workflows/_deploy_lambda.yml
vendored
|
|
@ -23,6 +23,18 @@ on:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
terraform_apply:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: 'false'
|
||||||
|
# can only be 'true' or 'false'
|
||||||
|
|
||||||
|
terraform_destroy:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: 'false'
|
||||||
|
# can only be 'true' or 'false'
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
AWS_ACCESS_KEY_ID:
|
AWS_ACCESS_KEY_ID:
|
||||||
required: true
|
required: true
|
||||||
|
|
@ -87,5 +99,11 @@ jobs:
|
||||||
-out=lambdaplan
|
-out=lambdaplan
|
||||||
|
|
||||||
- name: Terraform Apply
|
- name: Terraform Apply
|
||||||
|
if: inputs.terraform_apply == 'true' && inputs.terraform_destroy != 'true'
|
||||||
working-directory: ${{ inputs.lambda_path }}
|
working-directory: ${{ inputs.lambda_path }}
|
||||||
run: terraform apply -auto-approve lambdaplan
|
run: terraform apply -auto-approve lambdaplan
|
||||||
|
|
||||||
|
- name: Terraform Destroy
|
||||||
|
if: inputs.terraform_destroy == 'true' && inputs.terraform_apply != 'true'
|
||||||
|
working-directory: ${{ inputs.lambda_path }}
|
||||||
|
run: terraform destroy -auto-approve
|
||||||
33
.github/workflows/deploy_terraform.yml
vendored
33
.github/workflows/deploy_terraform.yml
vendored
|
|
@ -4,29 +4,43 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "**"
|
- "**"
|
||||||
|
paths:
|
||||||
|
- 'infrastructure/terraform/**'
|
||||||
|
- '.github/workflows/deploy_terraform.yml'
|
||||||
|
- '.github/workflows/_build_image.yml'
|
||||||
|
- '.github/workflows/_deploy_lambda.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
determine_stage:
|
determine_stage:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
stage: ${{ steps.set-stage.outputs.stage }}
|
stage: ${{ steps.set-stage.outputs.stage }}
|
||||||
|
terraform_apply: ${{ steps.set-stage.outputs.terraform_apply }}
|
||||||
|
|
||||||
|
env:
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_REGION: ${{ secrets.DEV_AWS_REGION }}
|
||||||
|
DEV_DB_HOST: ${{ secrets.DEV_DB_HOST }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Determine stage from branch
|
- name: Determine stage from branch
|
||||||
id: set-stage
|
id: set-stage
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
env
|
|
||||||
BRANCH="${GITHUB_REF_NAME}"
|
BRANCH="${GITHUB_REF_NAME}"
|
||||||
|
|
||||||
if [[ "$BRANCH" == "prod" ]]; then
|
if [[ "$BRANCH" == "prod" ]]; then
|
||||||
echo "stage=prod" >> "$GITHUB_OUTPUT"
|
echo "stage=prod" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "terraform_apply=false" >> "$GITHUB_OUTPUT"
|
||||||
elif [[ "$BRANCH" == "dev" ]]; then
|
elif [[ "$BRANCH" == "dev" ]]; then
|
||||||
echo "stage=dev" >> "$GITHUB_OUTPUT"
|
echo "stage=dev" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "terraform_apply=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
|
# Feature branch
|
||||||
echo "stage=dev" >> "$GITHUB_OUTPUT"
|
echo "stage=dev" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "terraform_apply=false" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
@ -93,6 +107,7 @@ jobs:
|
||||||
stage: ${{ needs.determine_stage.outputs.stage }}
|
stage: ${{ needs.determine_stage.outputs.stage }}
|
||||||
ecr_repo: address2uprn-${{ needs.determine_stage.outputs.stage }}
|
ecr_repo: address2uprn-${{ needs.determine_stage.outputs.stage }}
|
||||||
image_digest: ${{ needs.address2uprn_image.outputs.image_digest }}
|
image_digest: ${{ needs.address2uprn_image.outputs.image_digest }}
|
||||||
|
terraform_apply: ${{ needs.determine_stage.outputs.terraform_apply }}
|
||||||
secrets:
|
secrets:
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
||||||
|
|
@ -109,10 +124,17 @@ jobs:
|
||||||
ecr_repo: postcode_splitter-${{ needs.determine_stage.outputs.stage }}
|
ecr_repo: postcode_splitter-${{ needs.determine_stage.outputs.stage }}
|
||||||
dockerfile_path: backend/postcode_splitter/handler/Dockerfile
|
dockerfile_path: backend/postcode_splitter/handler/Dockerfile
|
||||||
build_context: .
|
build_context: .
|
||||||
|
build_args: |
|
||||||
|
DEV_DB_HOST=$DEV_DB_HOST
|
||||||
|
DEV_DB_PORT=$DEV_DB_PORT
|
||||||
|
DEV_DB_NAME=$DEV_DB_NAME
|
||||||
secrets:
|
secrets:
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
||||||
AWS_REGION: ${{ secrets.DEV_AWS_REGION }}
|
AWS_REGION: ${{ secrets.DEV_AWS_REGION }}
|
||||||
|
DEV_DB_HOST: ${{ secrets.DEV_DB_HOST }}
|
||||||
|
DEV_DB_PORT: ${{ secrets.DEV_DB_PORT }}
|
||||||
|
DEV_DB_NAME: ${{ secrets.DEV_DB_NAME }}
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 3️⃣ Deploy Postcode Splitter Lambda
|
# 3️⃣ Deploy Postcode Splitter Lambda
|
||||||
|
|
@ -126,6 +148,7 @@ jobs:
|
||||||
stage: ${{ needs.determine_stage.outputs.stage }}
|
stage: ${{ needs.determine_stage.outputs.stage }}
|
||||||
ecr_repo: postcode_splitter-${{ needs.determine_stage.outputs.stage }}
|
ecr_repo: postcode_splitter-${{ needs.determine_stage.outputs.stage }}
|
||||||
image_digest: ${{ needs.postcodeSplitter_image.outputs.image_digest }}
|
image_digest: ${{ needs.postcodeSplitter_image.outputs.image_digest }}
|
||||||
|
terraform_apply: ${{ needs.determine_stage.outputs.terraform_apply }}
|
||||||
secrets:
|
secrets:
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
||||||
|
|
@ -165,8 +188,8 @@ jobs:
|
||||||
stage: ${{ needs.determine_stage.outputs.stage }}
|
stage: ${{ needs.determine_stage.outputs.stage }}
|
||||||
ecr_repo: condition-etl-${{ needs.determine_stage.outputs.stage }}
|
ecr_repo: condition-etl-${{ needs.determine_stage.outputs.stage }}
|
||||||
image_digest: ${{ needs.condition_etl_image.outputs.image_digest }}
|
image_digest: ${{ needs.condition_etl_image.outputs.image_digest }}
|
||||||
|
terraform_apply: ${{ needs.determine_stage.outputs.terraform_apply }}
|
||||||
secrets:
|
secrets:
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
||||||
AWS_REGION: ${{ secrets.DEV_AWS_REGION }}
|
AWS_REGION: ${{ secrets.DEV_AWS_REGION }}
|
||||||
|
|
||||||
5
.github/workflows/unit_tests.yml
vendored
5
.github/workflows/unit_tests.yml
vendored
|
|
@ -4,9 +4,6 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- "**"
|
- "**"
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- "**"
|
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
@ -30,4 +27,4 @@ jobs:
|
||||||
env:
|
env:
|
||||||
EPC_AUTH_TOKEN: ${{ secrets.DEV_EPC_AUTH_TOKEN }}
|
EPC_AUTH_TOKEN: ${{ secrets.DEV_EPC_AUTH_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
make test
|
make test
|
||||||
Loading…
Add table
Reference in a new issue