Skip to content

Commit

Permalink
Refactor Cloudflare credentials and Terraform variables in action.yam…
Browse files Browse the repository at this point in the history
…l files
  • Loading branch information
adamlahbib committed Nov 16, 2024
1 parent 8142ad1 commit 35990e4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
6 changes: 1 addition & 5 deletions .github/actions/terraform-apply/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions .github/actions/terraform-destroy/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions .github/actions/terraform-plan/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sync-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down

0 comments on commit 35990e4

Please sign in to comment.