From f8de38234bb05dc1b1dda187632d13f9004dc8be Mon Sep 17 00:00:00 2001 From: shanice-skylight <150187231+shanice-skylight@users.noreply.github.com> Date: Tue, 5 Nov 2024 08:42:34 -0500 Subject: [PATCH] Deployment Workflow (#101) * added workflow to trigger aws deployment via dibbs-query-connector * added extract service step --- .github/workflows/target_workflow.yml | 91 +++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/target_workflow.yml diff --git a/.github/workflows/target_workflow.yml b/.github/workflows/target_workflow.yml new file mode 100644 index 00000000..e6d41faa --- /dev/null +++ b/.github/workflows/target_workflow.yml @@ -0,0 +1,91 @@ +name: QC Target Workflow + +on: + repository_dispatch: + types: [trigger-workflow] + +permissions: + id-token: write + contents: read + packages: write + +jobs: + build: + runs-on: ubuntu-latest + environment: main + defaults: + run: + shell: bash + working-directory: ./terraform/aws/implementation + outputs: + tf_env: ${{ steps.set-environment.outputs.tf_env }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.client_payload.sha }} + + + - name : Extract Service Name & Version + run: | + # Parse the service name from the payload + service_name=${{ github.event.client_payload.service }} + echo "Service Name: $service_name" + + # Parse the version from the payload + version=${{ github.event.client_payload.version }} + echo "Version: $version" + + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v3 + + - name: Setup Helm + uses: azure/setup-helm@v4.2.0 + + - name: Setup jq + uses: dcarbone/install-jq-action@v2 + with: + version: '1.7' + + - name: configure aws credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + role-session-name: githubDeploymentWorkflow + aws-region: ${{ vars.AWS_REGION }} + + - name: Set environment + id: set-environment + run: |- + echo "tf_env=$( + if [[ "${{ github.event.inputs.environment }}" != "" ]]; then + echo ${{ github.event.inputs.environment }} + else + echo dev + fi + )" >> $GITHUB_OUTPUT + + - name: Load input variables + env: + SMARTY_AUTH_ID: ${{ secrets.SMARTY_AUTH_ID }} + SMARTY_AUTH_TOKEN: ${{ secrets.SMARTY_AUTH_TOKEN }} + ENABLE_COGNITO: false + BUCKET: phdi-playground-tfstate-${{ steps.set-environment.outputs.tf_env }} + DYNAMODB_TABLE: phdi-playground-tfstate-lock-${{ steps.set-environment.outputs.tf_env }} + + run: | + echo smarty_auth_id=\""$SMARTY_AUTH_ID"\" >> terraform.tfvars + echo smarty_auth_token=\""$SMARTY_AUTH_TOKEN"\" >> terraform.tfvars + echo enable_cognito=\""$ENABLE_COGNITO"\" >> terraform.tfvars + echo bucket=\""$BUCKET"\" >> backend.tfvars + echo dynamodb_table=\""$DYNAMODB_TABLE"\" >> backend.tfvars + + - name: terraform + env: + TF_ENV: ${{ steps.set-environment.outputs.tf_env }} + GH_TOKEN: ${{ github.token }} + run: | + terraform init -backend-config=backend.tfvars + terraform workspace select -or-create $TF_ENV + terraform apply -auto-approve -lock-timeout=30m