Model/.github/workflows/deploy_terraform.yml
2026-02-03 07:56:48 +00:00

65 lines
1.8 KiB
YAML

name: Deploy terraform stack
on:
push:
branches:
- "**"
jobs:
Deploy shared terraform stack:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}"
aws-secret-access-key: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}"
aws-region: eu-west-2
env:
AWS_PROFILE: "DevAdmin"
- name: Setup Terraform
shell: bash
uses: hashicorp/setup-terraform@v3
- name: Terraform Init
working-directory: ./infrastructure/terraform/shared
shell: bash
run: terraform init -reconfigure
- name: Terraform Workspace
working-directory: ./infrastructure/terraform/shared
shell: bash
run: terraform workspace select dev || terraform workspace new dev
- name: Terraform Plan (shared)
working-directory: ./infrastructure/terraform/shared
shell: bash
run: terraform plan -var-file=dev.tfvars -out=tfplan
# - name: Terraform Apply
# working-directory: ./infrastructure/terraform/shared
# shell: bash
# run: terraform apply -auto-approve tfplan
# # apply shared dev
# - name: Terraform Apply (shared)
# run: |
# cd infrastructure/terraform/shared
# terraform apply -auto-approve -var-file=dev.tfvars
# - name: Build & push image
# run: |
# IMAGE_TAG=address2uprn-${GITHUB_SHA}
# IMAGE_URI=${AWS_ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/lambda-shared-dev:${IMAGE_TAG}
# docker build -t $IMAGE_URI .
# docker push $IMAGE_URI
# echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV