From 3bf87bb9c08ccfd3d87f5052d7a85f5a27263902 Mon Sep 17 00:00:00 2001 From: Nicolas BRIERE Date: Wed, 24 May 2023 15:03:53 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20Remove=20Terraform=20usele?= =?UTF-8?q?ss=20status=20steps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/terraform.yml | 81 ++------------------------------- 1 file changed, 3 insertions(+), 78 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 4e83bb6..e17cd51 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -57,7 +57,7 @@ jobs: uses: tailscale/github-action@v1 with: authkey: ${{ secrets.TAILSCALE_AUTH_KEY }} - version: 1.36.0 + version: ${{ vars.TAILSCALE_VERSION }} - name: Import Secrets id: secrets @@ -89,7 +89,6 @@ jobs: id: fmt working-directory: ${{ inputs.workdir || github.workspace }} run: terraform -chdir=${{ inputs.terraform_dir }} fmt -check - continue-on-error: true - name: Terraform Init id: init @@ -100,7 +99,6 @@ jobs: id: validate working-directory: ${{ inputs.workdir || github.workspace }} run: terraform -chdir=${{ inputs.terraform_dir }} validate - continue-on-error: true - name: Terraform Workspace id: workspace @@ -110,82 +108,9 @@ jobs: - name: Terraform Plan id: plan working-directory: ${{ inputs.workdir || github.workspace }} - run: | - terraform -chdir=${{ inputs.terraform_dir }} plan -out=tfplan -no-color -input=false ${{ inputs.terraform_args }} - continue-on-error: true - - - name: Publish Terraform summary - run: | - echo "#### Terraform Format and Style 🖌\'${{ steps.fmt.outcome }}\'" >> $GITHUB_STEP_SUMMARY - echo "#### Terraform Initialization ⚙️\'${{ steps.init.outcome }}\'" >> $GITHUB_STEP_SUMMARY - echo "#### Terraform Validation 🤖\'${{ steps.validate.outcome }}\'" >> $GITHUB_STEP_SUMMARY - echo "#### Terraform Plan 📖\'${{ steps.plan.outcome }}\'" >> $GITHUB_STEP_SUMMARY - - - name: PR comment Terraform - uses: actions/github-script@v6 - if: github.event_name == 'pull_request' - env: - PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - // 1. Retrieve existing bot comments for the PR - const { data: comments } = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - }) - const botComment = comments.find(comment => { - return comment.user.type === 'Bot' && comment.body.includes('Terraform Format and Style ${{ inputs.terraform_substep_name }}') - }) - - // 2. Prepare format of the comment - const output = `#### Terraform Format and Style ${{ inputs.terraform_substep_name }} 🖌\`${{ steps.fmt.outcome }}\` - #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` - #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` -
Validation Output - - \`\`\`\n - ${{ steps.validate.outputs.stdout }} - \`\`\` - -
- - #### Terraform Plan 📖\`${{ steps.plan.outcome }}\` - -
Show Plan - - \`\`\`\n - ${process.env.PLAN} - \`\`\` - -
- - *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`; - - // 3. If we have a comment, update it, otherwise create a new one - if (botComment) { - github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: botComment.id, - body: output - }) - } else { - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: output - }) - } - - - name: Terraform Status - if: steps.plan.outcome == 'failure' || steps.validate.outcome == 'failure' || steps.fmt.outcome == 'failure' - run: exit 1 + run: terraform -chdir=${{ inputs.terraform_dir }} plan -out=tfplan -no-color -input=false ${{ inputs.terraform_args }} - name: Terraform Apply if: ${{ inputs.terraform_check_only == false }} working-directory: ${{ inputs.workdir || github.workspace }} - run: | - terraform -chdir=${{ inputs.terraform_dir }} apply -auto-approve -input=false tfplan + run: terraform -chdir=${{ inputs.terraform_dir }} apply -auto-approve -input=false tfplan