mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Added github actions deployment script
This commit is contained in:
parent
3036512f85
commit
b77437226f
1 changed files with 61 additions and 0 deletions
61
infrastructure/terraform/.github/workflows/deploy.yml
vendored
Normal file
61
infrastructure/terraform/.github/workflows/deploy.yml
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
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
|
||||
role-to-assume: arn:aws:iam::account-id:role/role-name-with-path
|
||||
env:
|
||||
AWS_PROFILE: "DevAdmin"
|
||||
|
||||
- name: Terraform Init
|
||||
run: terraform init
|
||||
|
||||
- name: Terraform Plan
|
||||
run: terraform plan -var-file=${{ github.event.pull_request.base.ref }}.tfvars
|
||||
|
||||
- name: Terraform Workspace
|
||||
run: 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: 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
|
||||
role-to-assume: arn:aws:iam::account-id:role/role-name-with-path
|
||||
env:
|
||||
AWS_PROFILE: "ProdAdmin"
|
||||
|
||||
- name: Deploy to Prod
|
||||
if: github.event.pull_request.base.ref == 'prod' && github.event.pull_request.merged == true
|
||||
run: terraform apply -var-file=prod.tfvars -auto-approve
|
||||
env:
|
||||
name: prod
|
||||
Loading…
Add table
Reference in a new issue