Skip to content

[WIP] Use pre/post orchestrate and execute custom actions #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion .github/workflows/pipelines-root.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ on:
required: false

env:

PIPELINES_CLI_VERSION: v0.36.2
PIPELINES_ACTIONS_VERSION: v3.4.3
PIPELINES_ACTIONS_VERSION: v3.4.3 # TODO: update to whatever version comes after we merge matching actions PR
BOILERPLATE_VERSION: v0.5.16
GRUNTWORK_INSTALLER_VERSION: v0.0.40

Expand Down Expand Up @@ -140,6 +141,13 @@ jobs:
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
PR_COMMENT_WRITE_TOKEN: ${{ steps.pipelines-infra-root-write-token.outputs.PIPELINES_TOKEN }}

- name: Pre Orchestrate Custom Action
uses: ./pipelines-actions/.github/custom-actions/pre-orchestrate
with:
PIPELINES_GRUNTWORK_READ_TOKEN: ${{ steps.pipelines-gruntwork-read-token.outputs.PIPELINES_TOKEN }}
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
PR_COMMENT_WRITE_TOKEN: ${{ steps.pipelines-infra-root-write-token.outputs.PIPELINES_TOKEN }}

- name: Pipelines Orchestrate
id: orchestrate
uses: ./pipelines-actions/.github/actions/pipelines-orchestrate
Expand All @@ -148,6 +156,14 @@ jobs:
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
PR_COMMENT_WRITE_TOKEN: ${{ steps.pipelines-infra-root-write-token.outputs.PIPELINES_TOKEN }}

- name: Post Orchestrate Custom Action
uses: ./pipelines-actions/.github/custom-actions/post-orchestrate
with:
PIPELINES_GRUNTWORK_READ_TOKEN: ${{ steps.pipelines-gruntwork-read-token.outputs.PIPELINES_TOKEN }}
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
PR_COMMENT_WRITE_TOKEN: ${{ steps.pipelines-infra-root-write-token.outputs.PIPELINES_TOKEN }}
jobs: ${{ steps.orchestrate.outputs.jobs }}

outputs:
pipelines_jobs: ${{ steps.orchestrate.outputs.jobs }}

Expand Down Expand Up @@ -299,6 +315,16 @@ jobs:
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
gruntwork_context: ${{ toJson(steps.gruntwork_context.outputs) }}

- name: Pre Execute Custom Action
uses: ./pipelines-actions/.github/custom-actions/pre-execute
with:
PIPELINES_GRUNTWORK_READ_TOKEN: ${{ steps.pipelines-gruntwork-read-token.outputs.PIPELINES_TOKEN }}
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
account_id: ${{ matrix.jobs.AccountId }}
account_name: ${{ matrix.jobs.Name }}
job: ${{ toJson(matrix.jobs) }}
gruntwork_context: ${{ toJson(steps.gruntwork_context.outputs) }}

- name: "[TerragruntExecute]: Authenticate with AWS and then Invoke Terragrunt"
id: terragrunt
if: ${{ steps.gruntwork_context.outputs.action == 'TERRAGRUNT_EXECUTE' }}
Expand All @@ -317,6 +343,19 @@ jobs:
infra_live_directory: "."
deploy_branch_name: ${{ steps.gruntwork_context.outputs.deploy_branch_name }}

- name: Post Execute Custom Action
uses: ./pipelines-actions/.github/custom-actions/post-execute
with:
PIPELINES_GRUNTWORK_READ_TOKEN: ${{ steps.pipelines-gruntwork-read-token.outputs.PIPELINES_TOKEN }}
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
account_id: ${{ matrix.jobs.AccountId }}
account_name: ${{ matrix.jobs.Name }}
job: ${{ toJson(matrix.jobs) }}
gruntwork_context: ${{ toJson(steps.gruntwork_context.outputs) }}
formatted_plan_output: ${{ steps.terragrunt.outputs.formatted_plan_output }}
execute_stdout_log: ${{ steps.terragrunt.outputs.execute_stdout_log }}
plan_folder: ${{ steps.terragrunt.outputs.plan_folder }}

- name: Get Logs URL
id: get_logs_url
uses: ./pipelines-actions/.github/actions/pipelines-get-job-logs-url
Expand Down
40 changes: 39 additions & 1 deletion .github/workflows/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ on:

env:
PIPELINES_CLI_VERSION: v0.36.2
PIPELINES_ACTIONS_VERSION: v3.4.3
PIPELINES_ACTIONS_VERSION: v3.4.3# TODO: update to whatever version comes after we merge matching actions PR

# GitHub Actions tends to hit resource exhaustion and kill running jobs
# if we leave parallelism unbounded, so we set the max to 10 for a sane default.
Expand Down Expand Up @@ -120,6 +120,13 @@ jobs:
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
PR_COMMENT_WRITE_TOKEN: ${{ steps.pipelines-propose-infra-change-token.outputs.PIPELINES_TOKEN }}

- name: Pre Orchestrate Custom Action
uses: ./pipelines-actions/.github/custom-actions/pre-orchestrate
with:
PIPELINES_GRUNTWORK_READ_TOKEN: ${{ steps.pipelines-gruntwork-read-token.outputs.PIPELINES_TOKEN }}
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
PR_COMMENT_WRITE_TOKEN: ${{ steps.pipelines-propose-infra-change-token.outputs.PIPELINES_TOKEN }}

- name: Pipelines Orchestrate
id: orchestrate
uses: ./pipelines-actions/.github/actions/pipelines-orchestrate
Expand All @@ -128,6 +135,14 @@ jobs:
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
PR_COMMENT_WRITE_TOKEN: ${{ steps.pipelines-propose-infra-change-token.outputs.PIPELINES_TOKEN }}

- name: Post Orchestrate Custom Action
uses: ./pipelines-actions/.github/custom-actions/post-orchestrate
with:
PIPELINES_GRUNTWORK_READ_TOKEN: ${{ steps.pipelines-gruntwork-read-token.outputs.PIPELINES_TOKEN }}
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
PR_COMMENT_WRITE_TOKEN: ${{ steps.pipelines-propose-infra-change-token.outputs.PIPELINES_TOKEN }}
jobs: ${{ steps.orchestrate.outputs.jobs }}

outputs:
pipelines_jobs: ${{ steps.orchestrate.outputs.jobs }}

Expand Down Expand Up @@ -206,6 +221,16 @@ jobs:
child_account_id: ${{ matrix.jobs.AdditionalData.ChildAccountId }}
account_names: ${{ matrix.jobs.AdditionalData.AccountNames }}

- name: Pre Execute Custom Action
uses: ./pipelines-actions/.github/custom-actions/pre-execute
with:
PIPELINES_GRUNTWORK_READ_TOKEN: ${{ steps.pipelines-gruntwork-read-token.outputs.PIPELINES_TOKEN }}
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
account_id: ${{ matrix.jobs.AccountId }}
account_name: ${{ matrix.jobs.Name }}
job: ${{ toJson(matrix.jobs) }}
gruntwork_context: ${{ toJson(steps.gruntwork_context.outputs) }}

- name: "Run terragrunt ${{ steps.gruntwork_context.outputs.terragrunt_command }} in ${{ steps.gruntwork_context.outputs.working_directory }}"
id: terragrunt
uses: ./pipelines-actions/.github/actions/pipelines-execute
Expand Down Expand Up @@ -245,6 +270,19 @@ jobs:
step_logs_url: ${{ steps.get_logs_url.outputs.step_logs_url }}
PR_COMMENT_WRITE_TOKEN: ${{ steps.pipelines-propose-infra-change-token.outputs.PIPELINES_TOKEN }}

- name: Post Execute Custom Action
uses: ./pipelines-actions/.github/custom-actions/post-execute
with:
PIPELINES_GRUNTWORK_READ_TOKEN: ${{ steps.pipelines-gruntwork-read-token.outputs.PIPELINES_TOKEN }}
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
account_id: ${{ matrix.jobs.AccountId }}
account_name: ${{ matrix.jobs.Name }}
job: ${{ toJson(matrix.jobs) }}
gruntwork_context: ${{ toJson(steps.gruntwork_context.outputs) }}
formatted_plan_output: ${{ steps.terragrunt.outputs.formatted_plan_output }}
execute_stdout_log: ${{ steps.terragrunt.outputs.execute_stdout_log }}
plan_folder: ${{ steps.terragrunt.outputs.plan_folder }}

outputs:
account_id: ${{ matrix.jobs.AccountId }}
branch: ${{ steps.gruntwork_context.outputs.branch }}
Expand Down