From c55f37ec171959a3ebf665c75ae8b42c2b47f0db Mon Sep 17 00:00:00 2001 From: smohiudd Date: Thu, 14 Dec 2023 11:40:35 -0700 Subject: [PATCH] add mono repo deploy --- .github/actions/terraform-deploy/action.yml | 60 +++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/actions/terraform-deploy/action.yml diff --git a/.github/actions/terraform-deploy/action.yml b/.github/actions/terraform-deploy/action.yml new file mode 100644 index 00000000..66fedfd0 --- /dev/null +++ b/.github/actions/terraform-deploy/action.yml @@ -0,0 +1,60 @@ +name: Deploy + +inputs: + env_aws_secret_name: + required: true + type: string + env-file: + type: string + default: ".env" + dir: + required: false + type: string + default: "." + script_path: + type: string + backend_stack_name: + type: string + +runs: + using: "composite" + + steps: + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + cache: "pip" + + - name: Install python dependencies + shell: bash + working-directory: ${{ inputs.dir }} + run: pip install -r deploy_requirements.txt + + - name: Get relevant environment configuration from aws secrets + shell: bash + working-directory: ${{ inputs.dir }} + env: + SECRET_SSM_NAME: ${{ inputs.env_aws_secret_name }} + AWS_DEFAULT_REGION: us-west-2 + run: | + if [[ -z "${{ inputs.script_path }}" ]]; then + ./scripts/sync-env.sh ${{ inputs.env_aws_secret_name }} + else + python ${{ inputs.script_path }} --secret-id ${{ inputs.env_aws_secret_name }} --stack-names ${{ inputs.backend_stack_name}} + source .env + echo "PREFIX=data-pipeline-$STAGE" >> ${{ inputs.env-file }} + fi + + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v2 + with: + terraform_version: 1.3.3 + + - name: Deploy + shell: bash + working-directory: ${{ inputs.dir }} + run: | + ./scripts/deploy.sh ${{ inputs.env-file }} <<< init + ./scripts/deploy.sh ${{ inputs.env-file }} <<< deploy \ No newline at end of file