diff --git a/.github/workflows/reusable-steps.yml b/.github/workflows/reusable-steps.yml new file mode 100644 index 000000000..fccdb12ca --- /dev/null +++ b/.github/workflows/reusable-steps.yml @@ -0,0 +1,46 @@ +name: Reusable Steps + +on: + workflow_call: + inputs: + component: + required: true + type: string + environment: + required: true + type: string + secrets: + GITHUB_TOKEN: + required: true + ACCOUNT_ID: + required: true + OP_SERVICE_ACCOUNT_TOKEN: + required: true + +jobs: + terragrunt-plan: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3.6.0 + + - name: Setup Terraform + uses: ./.github/actions/setup-terraform + with: + role_to_assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/notification-terraform-plan + role_session_name: NotifyTerraformPlan + + - name: Install 1Pass CLI + run: | + curl -o 1pass.deb https://downloads.1password.com/linux/debian/amd64/stable/1password-cli-amd64-latest.deb + sudo dpkg -i 1pass.deb + + - name: Retrieve TFVars + run: | + op read op://4eyyuwddp6w4vxlabrr2i2duxm/"TFVars - ${{ inputs.environment }}"/notesPlain > /var/tmp/${{ inputs.environment }}.tfvars + + - name: Terragrunt plan ${{ inputs.component }} + run: | + cd env/${{ inputs.environment }}/${{ inputs.component }} + terragrunt plan --terragrunt-non-interactive \ No newline at end of file diff --git a/.github/workflows/terragrunt_plan_dev.yml b/.github/workflows/terragrunt_plan_dev.yml index 6e034ac02..e915d9522 100644 --- a/.github/workflows/terragrunt_plan_dev.yml +++ b/.github/workflows/terragrunt_plan_dev.yml @@ -120,36 +120,14 @@ jobs: - 'env/${{env.ENVIRONMENT}}/newrelic/**' terragrunt-plan-common: + if: | + needs.terragrunt-filter.outputs.common == 'true' runs-on: ubuntu-latest needs: terragrunt-filter - steps: - - - name: Install 1Pass CLI - run: | - curl -o 1pass.deb https://downloads.1password.com/linux/debian/amd64/stable/1password-cli-amd64-latest.deb - sudo dpkg -i 1pass.deb - - - name: Retrieve TFVars - run: | - op read op://4eyyuwddp6w4vxlabrr2i2duxm/"TFVars - ${{env.ENVIRONMENT}}"/notesPlain > /var/tmp/${{env.ENVIRONMENT}}.tfvars - - - name: Checkout - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - - name: setup-terraform - uses: ./.github/actions/setup-terraform - with: - role_to_assume: arn:aws:iam::${{env.ACCOUNT_ID}}:role/notification-terraform-plan - role_session_name: NotifyTerraformPlan - - - name: Terragrunt plan common - if: | - needs.terragrunt-filter.outputs.common == 'true' - - run: | - op read op://4eyyuwddp6w4vxlabrr2i2duxm/"TFVars - ${{env.ENVIRONMENT}}"/notesPlain > /var/tmp/${{env.ENVIRONMENT}}.tfvars - cd env/${{env.ENVIRONMENT}}/common - terragrunt plan --terragrunt-non-interactive + uses: ./.github/workflows/reusable-steps.yml + with: + component: common + environment: ${{ env.ENVIRONMENT }} # terragrunt-plan-ecr: # if: |