mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
59 lines
1.9 KiB
YAML
59 lines
1.9 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- dev
|
|
- prod
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup Terraform
|
|
uses: hashicorp/setup-terraform@v1
|
|
with:
|
|
terraform_version: 1.0.5
|
|
|
|
- name: Configure AWS credentials (DevAdmin)
|
|
uses: aws-actions/configure-aws-credentials@v1
|
|
with:
|
|
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
|
|
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
|
|
aws-region: eu-west-2
|
|
env:
|
|
AWS_PROFILE: "DevAdmin"
|
|
|
|
- name: Terraform Init
|
|
run: cd infrastructure/terraform && terraform init
|
|
|
|
- name: Terraform Plan
|
|
run: cd infrastructure/terraform && terraform plan -var-file=${{ github.event.pull_request.base.ref }}.tfvars
|
|
|
|
- name: Terraform Workspace
|
|
run: cd infrastructure/terraform && terraform workspace new ${{ github.event.pull_request.base.ref }}
|
|
|
|
- name: Deploy to Dev
|
|
if: github.event.pull_request.base.ref == 'dev' && github.event.pull_request.merged == true
|
|
run: cd infrastructure/terraform && terraform apply -var-file=dev.tfvars -auto-approve
|
|
env:
|
|
name: dev
|
|
|
|
- name: Configure AWS credentials (ProdAdmin)
|
|
uses: aws-actions/configure-aws-credentials@v1
|
|
with:
|
|
aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }}
|
|
aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }}
|
|
aws-region: eu-west-2
|
|
env:
|
|
AWS_PROFILE: "ProdAdmin"
|
|
|
|
- name: Deploy to Prod
|
|
if: github.event.pull_request.base.ref == 'prod' && github.event.pull_request.merged == true
|
|
run: cd infrastructure/terraform && terraform apply -var-file=prod.tfvars -auto-approve
|
|
env:
|
|
name: prod
|