From 6c4659b9b25f551e6724bba4eda76f90b8c3530c Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 12:43:09 +0200 Subject: [PATCH 01/21] Add test step --- .github/workflows/go/pr.yaml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go/pr.yaml b/.github/workflows/go/pr.yaml index bbbd5114..9cbabf15 100644 --- a/.github/workflows/go/pr.yaml +++ b/.github/workflows/go/pr.yaml @@ -35,4 +35,31 @@ jobs: VALIDATE_ALL_CODEBASE: false VALIDATE_DOCKERFILE: true VALIDATE_TERRAFORM_TFLINT: true - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }} + + test: + name: Test + runs-on: ubuntu-latest + needs: + - linter + + steps: + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: "^1.18.0" + + - name: Checkout code + uses: actions/checkout@v3 + + - uses: actions/cache@v3.0.2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Test + run: make test + env: + GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }} From 5993de8b1b263e07067aac47aff457a2e04ae212 Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 12:50:43 +0200 Subject: [PATCH 02/21] Update workflow file location --- .github/workflows/go/main.yaml | 0 .github/workflows/{go/pr.yaml => pr-go.yaml} | 46 ++++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) delete mode 100644 .github/workflows/go/main.yaml rename .github/workflows/{go/pr.yaml => pr-go.yaml} (63%) diff --git a/.github/workflows/go/main.yaml b/.github/workflows/go/main.yaml deleted file mode 100644 index e69de29b..00000000 diff --git a/.github/workflows/go/pr.yaml b/.github/workflows/pr-go.yaml similarity index 63% rename from .github/workflows/go/pr.yaml rename to .github/workflows/pr-go.yaml index 9cbabf15..cd87cab3 100644 --- a/.github/workflows/go/pr.yaml +++ b/.github/workflows/pr-go.yaml @@ -37,29 +37,29 @@ jobs: VALIDATE_TERRAFORM_TFLINT: true GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }} - test: - name: Test - runs-on: ubuntu-latest - needs: - - linter + test: + name: Test + runs-on: ubuntu-latest + needs: + - linter - steps: - - name: Setup go - uses: actions/setup-go@v3 - with: - go-version: "^1.18.0" - - - name: Checkout code - uses: actions/checkout@v3 + steps: + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: "^1.18.0" + + - name: Checkout code + uses: actions/checkout@v3 - - uses: actions/cache@v3.0.2 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + - uses: actions/cache@v3.0.2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - - name: Test - run: make test - env: - GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }} + - name: Test + run: make test + env: + GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }} From 1c973dd37cf6c163f2550cb01b1b9b1b2f14c3ff Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 12:53:14 +0200 Subject: [PATCH 03/21] Use slim image --- .github/workflows/pr-go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-go.yaml b/.github/workflows/pr-go.yaml index cd87cab3..aff47d41 100644 --- a/.github/workflows/pr-go.yaml +++ b/.github/workflows/pr-go.yaml @@ -28,7 +28,7 @@ jobs: # Run Linter against code base # ################################ - name: Lint Code Base - uses: github/super-linter@v4 + uses: github/super-linter/slim@v4 env: GOPRIVATE: input.go_private DEFAULT_BRANCH: input.main_branch From db72c7025f86e31b596072a3e04460658cd8075e Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 12:54:28 +0200 Subject: [PATCH 04/21] Fix parameters --- .github/workflows/pr-go.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-go.yaml b/.github/workflows/pr-go.yaml index aff47d41..3e987e73 100644 --- a/.github/workflows/pr-go.yaml +++ b/.github/workflows/pr-go.yaml @@ -30,8 +30,8 @@ jobs: - name: Lint Code Base uses: github/super-linter/slim@v4 env: - GOPRIVATE: input.go_private - DEFAULT_BRANCH: input.main_branch + GOPRIVATE: ${{ inputs.go_private }} + DEFAULT_BRANCH: ${{ inputs.main_branch }} VALIDATE_ALL_CODEBASE: false VALIDATE_DOCKERFILE: true VALIDATE_TERRAFORM_TFLINT: true From 742daafd3cc35ec3b592907d8b8a9603e33c543b Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 14:08:12 +0200 Subject: [PATCH 05/21] Add PR terraform --- .github/workflows/pr-terraform.yaml | 87 +++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/pr-terraform.yaml diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml new file mode 100644 index 00000000..1cd345f1 --- /dev/null +++ b/.github/workflows/pr-terraform.yaml @@ -0,0 +1,87 @@ +on: + workflow_call: + inputs: + role_to_assume: + required: true + type: string + role_session_name: + required: true + type: string + aws_region: + required: true + type: string + working_directory: + required: true + type: string + stagign_terraform_variables: + required: true + type: string + prod_terraform_variables: + required: true + type: string + +permissions: + id-token: write + contents: read + pull-requests: write + statuses: write + +jobs: + terraform: + name: Terraform + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ${{ inputs.working_directory }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Configure AWS Credentials + id: aws + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ inputs.role_to_assume }} + role-session-name: ${{ inputs.role_session_name }} + aws-region: ${{ inputs.aws_region }} + + - name: Create Staging TF VARS file + run: 'echo "${{ inputs.staging_terraform_variables }}" > staging.tfvars' + shell: bash + + - name: Create Prod TF VARS file + run: 'echo "${{ inputs.prod_terraform_variables }}" > prod.tfvars' + shell: bash + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v2 + with: + terraform_version: ~1.0 + + - name: Terraform Format + id: fmt + run: terraform fmt -check + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + + - name: Terraform Staging Plan + id: plan-staging + run: terraform plan -no-color -var-file=staging.tfvars + env: + TF_WORKSPACE: staging + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Terraform Prod Plan + id: plan-prod + run: terraform plan -no-color -var-file=prod.tfvars + env: + TF_WORKSPACE: prod + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b70213e37e52bf18f51446e9bb566a054045c91d Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 14:17:26 +0200 Subject: [PATCH 06/21] Update role --- .github/workflows/pr-terraform.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index 1cd345f1..8f64b554 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -1,7 +1,7 @@ on: workflow_call: inputs: - role_to_assume: + role_name: required: true type: string role_session_name: @@ -43,7 +43,7 @@ jobs: id: aws uses: aws-actions/configure-aws-credentials@v1 with: - role-to-assume: ${{ inputs.role_to_assume }} + role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ inputs.role_name }} role-session-name: ${{ inputs.role_session_name }} aws-region: ${{ inputs.aws_region }} From 31fdda1b330c91286d55b3209e5d50311aa764eb Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 14:19:55 +0200 Subject: [PATCH 07/21] Fix parameter name --- .github/workflows/pr-terraform.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index 8f64b554..e49d50e6 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -13,7 +13,7 @@ on: working_directory: required: true type: string - stagign_terraform_variables: + staging_terraform_variables: required: true type: string prod_terraform_variables: From 1c3cc40efc0f4f9e288a526400f4494d819a8ddb Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 14:29:53 +0200 Subject: [PATCH 08/21] Update to json --- .github/workflows/pr-terraform.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index e49d50e6..adc03164 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -48,11 +48,11 @@ jobs: aws-region: ${{ inputs.aws_region }} - name: Create Staging TF VARS file - run: 'echo "${{ inputs.staging_terraform_variables }}" > staging.tfvars' + run: 'echo "${{ inputs.staging_terraform_variables }}" > staging.tfvars.json' shell: bash - name: Create Prod TF VARS file - run: 'echo "${{ inputs.prod_terraform_variables }}" > prod.tfvars' + run: 'echo "${{ inputs.prod_terraform_variables }}" > prod.tfvars.json' shell: bash - name: Setup Terraform From 46a5dde55c1051457d955e67244728c84b9be1f3 Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 14:31:11 +0200 Subject: [PATCH 09/21] Fix var file --- .github/workflows/pr-terraform.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index adc03164..ab6351c6 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -74,14 +74,14 @@ jobs: - name: Terraform Staging Plan id: plan-staging - run: terraform plan -no-color -var-file=staging.tfvars + run: terraform plan -no-color -var-file=staging.tfvars.json env: TF_WORKSPACE: staging GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Terraform Prod Plan id: plan-prod - run: terraform plan -no-color -var-file=prod.tfvars + run: terraform plan -no-color -var-file=prod.tfvars.json env: TF_WORKSPACE: prod GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 7dcc75b70c23b476ccf1fd39fc4e65c0c5ad7dac Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 14:41:11 +0200 Subject: [PATCH 10/21] Escape quote --- .github/workflows/pr-terraform.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index ab6351c6..ae06f0dc 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -48,11 +48,11 @@ jobs: aws-region: ${{ inputs.aws_region }} - name: Create Staging TF VARS file - run: 'echo "${{ inputs.staging_terraform_variables }}" > staging.tfvars.json' + run: 'echo ''${{ inputs.staging_terraform_variables }}'' > staging.tfvars.json' shell: bash - name: Create Prod TF VARS file - run: 'echo "${{ inputs.prod_terraform_variables }}" > prod.tfvars.json' + run: 'echo ''${{ inputs.prod_terraform_variables }}'' > prod.tfvars.json' shell: bash - name: Setup Terraform From 5bea29809014964522e2eae94bcb26f194d87b0d Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 14:49:15 +0200 Subject: [PATCH 11/21] Remove input --- .github/workflows/pr-terraform.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index ae06f0dc..98370286 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -13,9 +13,6 @@ on: working_directory: required: true type: string - staging_terraform_variables: - required: true - type: string prod_terraform_variables: required: true type: string @@ -48,7 +45,7 @@ jobs: aws-region: ${{ inputs.aws_region }} - name: Create Staging TF VARS file - run: 'echo ''${{ inputs.staging_terraform_variables }}'' > staging.tfvars.json' + run: 'echo ''${{ secrets.STAGING_TFVARS_JSON }}'' > staging.tfvars.json' shell: bash - name: Create Prod TF VARS file From c0d224ec0e4ce0208c74896b1f7f8c17c42dc8d1 Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 14:54:32 +0200 Subject: [PATCH 12/21] Debug --- .github/workflows/pr-terraform.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index 98370286..753e0918 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -52,6 +52,13 @@ jobs: run: 'echo ''${{ inputs.prod_terraform_variables }}'' > prod.tfvars.json' shell: bash + - name: Archive staging artifacts + uses: actions/upload-artifact@v3 + with: + name: staging-variables + path: | + ./staging.tfvars.json + - name: Setup Terraform uses: hashicorp/setup-terraform@v2 with: From 8b415e9dc57828d05e9174168a790052a425a5f7 Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 14:56:59 +0200 Subject: [PATCH 13/21] Update artifact --- .github/workflows/pr-terraform.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index 753e0918..51f2c975 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -56,8 +56,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: staging-variables - path: | - ./staging.tfvars.json + path: staging.tfvars.json - name: Setup Terraform uses: hashicorp/setup-terraform@v2 From ff715abda605173810db0dd772a60f212b9eb385 Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 14:59:44 +0200 Subject: [PATCH 14/21] test --- .github/workflows/pr-terraform.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index 51f2c975..14f4f003 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -56,7 +56,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: staging-variables - path: staging.tfvars.json + path: . - name: Setup Terraform uses: hashicorp/setup-terraform@v2 From 15908ed1da5ea5af52926436e6485d682ec876b7 Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 15:23:49 +0200 Subject: [PATCH 15/21] Download artifacts --- .github/workflows/pr-terraform.yaml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index 14f4f003..6c30c2f2 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -13,9 +13,6 @@ on: working_directory: required: true type: string - prod_terraform_variables: - required: true - type: string permissions: id-token: write @@ -44,19 +41,17 @@ jobs: role-session-name: ${{ inputs.role_session_name }} aws-region: ${{ inputs.aws_region }} - - name: Create Staging TF VARS file - run: 'echo ''${{ secrets.STAGING_TFVARS_JSON }}'' > staging.tfvars.json' - shell: bash - - - name: Create Prod TF VARS file - run: 'echo ''${{ inputs.prod_terraform_variables }}'' > prod.tfvars.json' - shell: bash - - - name: Archive staging artifacts - uses: actions/upload-artifact@v3 + - name: Download Staging Variables + uses: actions/download-artifact@v3 with: name: staging-variables - path: . + path: ${{ inputs.working_directory }} + + - name: Download Prod Variables + uses: actions/download-artifact@v3 + with: + name: prod-variables + path: ${{ inputs.working_directory }} - name: Setup Terraform uses: hashicorp/setup-terraform@v2 From 7998660e30b3292f67cbd902eff7fa4904d464a8 Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 15:30:56 +0200 Subject: [PATCH 16/21] Rename workflow --- .github/workflows/pr-go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-go.yaml b/.github/workflows/pr-go.yaml index 3e987e73..3030d704 100644 --- a/.github/workflows/pr-go.yaml +++ b/.github/workflows/pr-go.yaml @@ -10,7 +10,7 @@ on: jobs: linter: - name: Lint Code Base + name: Linter # Set the agent to run on runs-on: ubuntu-latest From ff842daf8cba50a6488c4e4adf9cd8a714f015df Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 15:35:45 +0200 Subject: [PATCH 17/21] Add comment step --- .github/workflows/pr-terraform.yaml | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index 6c30c2f2..18831e14 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -83,3 +83,72 @@ jobs: env: TF_WORKSPACE: prod GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/github-script@v6 + if: github.event_name == 'pull_request' + env: + PLAN_STAGING: "terraform\n${{ steps.plan-staging.outputs.stdout }}" + PLAN_PROD: "terraform\n${{ steps.plan-prod.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') + }) + + // 2. Prepare format of the comment + const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` + #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` + #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` +
Validation Output + + \`\`\`\n + ${{ steps.validate.outputs.stdout }} + \`\`\` + +
+ + #### Terraform Staging Plan 📖\`${{ steps.plan-staging.outcome }}\` + +
Show Staging Plan + + \`\`\`\n + ${process.env.PLAN_STAGING} + \`\`\` + +
+ + #### Terraform Prod Plan 📖\`${{ steps.plan-prod.outcome }}\` + +
Show Prod Plan + + \`\`\`\n + ${process.env.PLAN_PROD} + \`\`\` + +
+ + *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 + }) + } From 7c0d750a4fc58de8556e2f26f8dfdaab1973458c Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 15:38:19 +0200 Subject: [PATCH 18/21] Update status check --- .github/workflows/pr-terraform.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/pr-terraform.yaml b/.github/workflows/pr-terraform.yaml index 18831e14..9cc85b05 100644 --- a/.github/workflows/pr-terraform.yaml +++ b/.github/workflows/pr-terraform.yaml @@ -152,3 +152,11 @@ jobs: body: output }) } + + - name: Terraform Staging Plan Status + if: steps.plan-staging.outcome == 'failure' + run: exit 1 + + - name: Terraform Prod Plan Status + if: steps.plan-prod.outcome == 'failure' + run: exit 1 From 3677104d0db9bf9c557884e3c29b1380042df9a9 Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 15:48:53 +0200 Subject: [PATCH 19/21] Enable Go check --- .github/workflows/pr-go.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-go.yaml b/.github/workflows/pr-go.yaml index 3030d704..b1e8f0ad 100644 --- a/.github/workflows/pr-go.yaml +++ b/.github/workflows/pr-go.yaml @@ -35,6 +35,7 @@ jobs: VALIDATE_ALL_CODEBASE: false VALIDATE_DOCKERFILE: true VALIDATE_TERRAFORM_TFLINT: true + VALIDATE_GO: true GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }} test: From 4da47bd72b99b26cccb25f9b054b38c29154c44a Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 16:14:08 +0200 Subject: [PATCH 20/21] Split workflows --- .github/workflows/linter-go.yaml | 39 ++++++++++++++++++++++++++++++++ .github/workflows/pr-go.yaml | 31 ------------------------- 2 files changed, 39 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/linter-go.yaml diff --git a/.github/workflows/linter-go.yaml b/.github/workflows/linter-go.yaml new file mode 100644 index 00000000..d9d11726 --- /dev/null +++ b/.github/workflows/linter-go.yaml @@ -0,0 +1,39 @@ +on: + workflow_call: + inputs: + go_private: + required: true + type: string + main_branch: + required: true + type: string + +jobs: + linter: + name: Linter + # Set the agent to run on + runs-on: ubuntu-latest + + steps: + ########################## + # Checkout the code base # + ########################## + - name: Checkout Code + uses: actions/checkout@v3 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 + + ################################ + # Run Linter against code base # + ################################ + - name: Lint Code Base + uses: github/super-linter/slim@v4 + env: + GOPRIVATE: ${{ inputs.go_private }} + DEFAULT_BRANCH: ${{ inputs.main_branch }} + VALIDATE_ALL_CODEBASE: false + VALIDATE_DOCKERFILE: true + VALIDATE_TERRAFORM_TFLINT: true + VALIDATE_GO: true + GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }} diff --git a/.github/workflows/pr-go.yaml b/.github/workflows/pr-go.yaml index b1e8f0ad..ec8b4ca4 100644 --- a/.github/workflows/pr-go.yaml +++ b/.github/workflows/pr-go.yaml @@ -9,40 +9,9 @@ on: type: string jobs: - linter: - name: Linter - # Set the agent to run on - runs-on: ubuntu-latest - - steps: - ########################## - # Checkout the code base # - ########################## - - name: Checkout Code - uses: actions/checkout@v3 - with: - # Full git history is needed to get a proper list of changed files within `super-linter` - fetch-depth: 0 - - ################################ - # Run Linter against code base # - ################################ - - name: Lint Code Base - uses: github/super-linter/slim@v4 - env: - GOPRIVATE: ${{ inputs.go_private }} - DEFAULT_BRANCH: ${{ inputs.main_branch }} - VALIDATE_ALL_CODEBASE: false - VALIDATE_DOCKERFILE: true - VALIDATE_TERRAFORM_TFLINT: true - VALIDATE_GO: true - GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }} - test: name: Test runs-on: ubuntu-latest - needs: - - linter steps: - name: Setup go From e33abbe97fdae3e02e82ce7a43ba7eaa3ff8d52f Mon Sep 17 00:00:00 2001 From: Jackson Coelho Date: Wed, 18 May 2022 16:16:32 +0200 Subject: [PATCH 21/21] Clean up inputs --- .github/workflows/pr-go.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/pr-go.yaml b/.github/workflows/pr-go.yaml index ec8b4ca4..6024aad6 100644 --- a/.github/workflows/pr-go.yaml +++ b/.github/workflows/pr-go.yaml @@ -4,9 +4,6 @@ on: go_private: required: true type: string - main_branch: - required: true - type: string jobs: test: