From 35990e41f99661993fd3815f71d0588aea115f60 Mon Sep 17 00:00:00 2001 From: adamlahbib Date: Sat, 16 Nov 2024 17:54:23 +0100 Subject: [PATCH] Refactor Cloudflare credentials and Terraform variables in action.yaml files --- .github/actions/terraform-apply/action.yaml | 6 +----- .github/actions/terraform-destroy/action.yaml | 6 +----- .github/actions/terraform-plan/action.yaml | 6 +----- .github/workflows/sync-and-deploy.yaml | 6 +++--- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/actions/terraform-apply/action.yaml b/.github/actions/terraform-apply/action.yaml index 097bf2f..db7c4f9 100644 --- a/.github/actions/terraform-apply/action.yaml +++ b/.github/actions/terraform-apply/action.yaml @@ -40,15 +40,11 @@ runs: aws-secret-access-key: ${{ inputs.aws-secret-access-key }} aws-region: ${{ inputs.aws-region }} - - name: Append Cloudflare Token to Terraform Variables - shell: bash - run: echo "CLOUDFLARE_TOKEN=${{ inputs.CLOUDFLARE_TOKEN }}" >> ./terraform/stages/${{ inputs.stage }}.tfvars - - name: Terraform Apply env: TF_VAR_GRAFANA_ADMIN_PASSWORD: ${{ inputs.GRAFANA_ADMIN_PASSWORD }} - TF_VAR_CLOUDFLARE_TOKEN: ${{ inputs.CLOUDFLARE_TOKEN }} TF_VAR_CLOUDFLARE_ZONE_ID: ${{ inputs.CLOUDFLARE_ZONE_ID }} + TF_VAR_CLOUDFLARE_TOKEN: ${{ inputs.CLOUDFLARE_TOKEN }} uses: dflook/terraform-apply@v1 with: path: ./terraform diff --git a/.github/actions/terraform-destroy/action.yaml b/.github/actions/terraform-destroy/action.yaml index 882302e..667015f 100644 --- a/.github/actions/terraform-destroy/action.yaml +++ b/.github/actions/terraform-destroy/action.yaml @@ -39,16 +39,12 @@ runs: aws-access-key-id: ${{ inputs.aws-access-key-id }} aws-secret-access-key: ${{ inputs.aws-secret-access-key }} aws-region: ${{ inputs.aws-region }} - - - name: Append Cloudflare Token to Terraform Variables - shell: bash - run: echo "CLOUDFLARE_TOKEN=${{ inputs.CLOUDFLARE_TOKEN }}" >> ./terraform/stages/${{ inputs.stage }}.tfvars - name: Terraform Destroy env: TF_VAR_GRAFANA_ADMIN_PASSWORD: ${{ inputs.GRAFANA_ADMIN_PASSWORD }} - TF_VAR_CLOUDFLARE_TOKEN: ${{ inputs.CLOUDFLARE_TOKEN }} TF_VAR_CLOUDFLARE_ZONE_ID: ${{ inputs.CLOUDFLARE_ZONE_ID }} + TF_VAR_CLOUDFLARE_TOKEN: ${{ inputs.CLOUDFLARE_TOKEN }} uses: dflook/terraform-destroy@v1 with: path: ./terraform diff --git a/.github/actions/terraform-plan/action.yaml b/.github/actions/terraform-plan/action.yaml index 16f7ddf..90a0932 100644 --- a/.github/actions/terraform-plan/action.yaml +++ b/.github/actions/terraform-plan/action.yaml @@ -47,15 +47,11 @@ runs: shell: bash run: echo "GITHUB_TOKEN=${{ inputs.github-token }}" >> $GITHUB_ENV - - name: Append Cloudflare Token to Terraform Variables - shell: bash - run: echo "CLOUDFLARE_TOKEN=${{ inputs.CLOUDFLARE_TOKEN }}" >> ./terraform/stages/${{ inputs.stage }}.tfvars - - name: Terraform Plan env: TF_VAR_GRAFANA_ADMIN_PASSWORD: ${{ inputs.GRAFANA_ADMIN_PASSWORD }} - TF_VAR_CLOUDFLARE_TOKEN: ${{ inputs.CLOUDFLARE_TOKEN }} TF_VAR_CLOUDFLARE_ZONE_ID: ${{ inputs.CLOUDFLARE_ZONE_ID }} + TF_VAR_CLOUDFLARE_TOKEN: ${{ inputs.CLOUDFLARE_TOKEN }} uses: dflook/terraform-plan@v1 with: path: ./terraform diff --git a/.github/workflows/sync-and-deploy.yaml b/.github/workflows/sync-and-deploy.yaml index c6cc62f..afd0b38 100644 --- a/.github/workflows/sync-and-deploy.yaml +++ b/.github/workflows/sync-and-deploy.yaml @@ -48,6 +48,9 @@ jobs: tfstate-bucket: ${{ env.TFSTATE_BUCKET }} tfstate-key: ${{ env.TFSTATE_KEY }} stage: ${{ env.stage }} + GRAFANA_ADMIN_PASSWORD: ${{ env.GRAFANA_ADMIN_PASSWORD }} + CLOUDFLARE_ZONE_ID: ${{ env.CLOUDFLARE_ZONE_ID }} + CLOUDFLARE_TOKEN: ${{ env.CLOUDFLARE_TOKEN }} deploy: needs: terraform-apply @@ -78,9 +81,6 @@ jobs: ecr-repository: ${{ env.ECR_REPOSITORY }} dockerfile: ./Dockerfile stage: ${{ env.stage }} - GRAFANA_ADMIN_PASSWORD: ${{ env.GRAFANA_ADMIN_PASSWORD }} - CLOUDFLARE_ZONE_ID: ${{ env.CLOUDFLARE_ZONE_ID }} - CLOUDFLARE_TOKEN: ${{ env.CLOUDFLARE_TOKEN }} - name: Update Kubeconfig run: aws eks update-kubeconfig --name ${{ env.EKS_CLUSTER_NAME }} --region ${{ env.AWS_REGION }}