Skip to content

Commit

Permalink
reusable logic
Browse files Browse the repository at this point in the history
  • Loading branch information
P0NDER0SA committed Sep 6, 2024
1 parent 44b1145 commit bcf282a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 28 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/reusable-steps.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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
34 changes: 6 additions & 28 deletions .github/workflows/terragrunt_plan_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down

0 comments on commit bcf282a

Please sign in to comment.