From fd3130b11b8e0ec0efe67e5036775db55a5851ae Mon Sep 17 00:00:00 2001 From: Yousif Akbar <11247449+yhakbar@users.noreply.github.com> Date: Mon, 13 May 2024 16:36:57 -0400 Subject: [PATCH 1/4] Adding PR URL communication --- action.yml | 20 ++++++++++++++++++++ templates/step-summary/boilerplate.yml | 4 ++++ templates/step-summary/step-summary.md | 7 +++++++ 3 files changed, 31 insertions(+) create mode 100644 templates/step-summary/boilerplate.yml create mode 100644 templates/step-summary/step-summary.md diff --git a/action.yml b/action.yml index 5e08ab5..dd69601 100644 --- a/action.yml +++ b/action.yml @@ -149,3 +149,23 @@ runs: 2. Merge this pull request. Once merged, Gruntwork Pipelines will `terragrunt apply` the baseline in the newly created AWS account(s). + + - name: "[ProvisionAccount]: Communicate PR URL" + shell: bash + if: ${{ steps.gruntwork_context.outputs.terragrunt_command == 'apply' }} + env: + ACTION_PATH: ${{ github.action_path }} + MERGED_PR_NUMBER: ${{ steps.get_pr_number.outputs.pr_number }} + CREATED_PR_URL: ${{ steps.create_pr.outputs.pull-request-url }} + run: | + boilerplate \ + --template-url "$ACTION_PATH/templates/step-summary" \ + --output-folder "." \ + --var PullRequestURL="$CREATED_PR_URL" + + cat step-summary.md >> "$GITHUB_STEP_SUMMARY" + + gh pr comment "$MERGED_PR_NUMBER" \ + -F step-summary.md + + rm -f step-summary.md diff --git a/templates/step-summary/boilerplate.yml b/templates/step-summary/boilerplate.yml new file mode 100644 index 0000000..ec2ab40 --- /dev/null +++ b/templates/step-summary/boilerplate.yml @@ -0,0 +1,4 @@ +variables: + - name: PullRequestURL + description: The URL for the pull request created as part of account creation + type: string diff --git a/templates/step-summary/step-summary.md b/templates/step-summary/step-summary.md new file mode 100644 index 0000000..47ee978 --- /dev/null +++ b/templates/step-summary/step-summary.md @@ -0,0 +1,7 @@ +### Baseline Pull Request + +Now that you've created your account, you're ready to review and merge the baseline pull request. + +This is the pull request that contains the initial resources you need in a new account to have it ready for use. + +To see the pull request, click [here]({{ .PullRequestURL }}). From c68524319e68c5c5485edafb6ed32fb8ca13f635 Mon Sep 17 00:00:00 2001 From: Yousif Akbar <11247449+yhakbar@users.noreply.github.com> Date: Mon, 13 May 2024 18:07:42 -0400 Subject: [PATCH 2/4] Passing token to comment update --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index dd69601..1f927d0 100644 --- a/action.yml +++ b/action.yml @@ -157,6 +157,7 @@ runs: ACTION_PATH: ${{ github.action_path }} MERGED_PR_NUMBER: ${{ steps.get_pr_number.outputs.pr_number }} CREATED_PR_URL: ${{ steps.create_pr.outputs.pull-request-url }} + GH_TOKEN: ${{ inputs.INFRA_ROOT_WRITE_TOKEN }} run: | boilerplate \ --template-url "$ACTION_PATH/templates/step-summary" \ From 246b3ca14970b3d2b6f5fd2dc42a9e47d9f13cee Mon Sep 17 00:00:00 2001 From: Yousif Akbar <11247449+yhakbar@users.noreply.github.com> Date: Mon, 13 May 2024 18:47:57 -0400 Subject: [PATCH 3/4] Switch to merged PR URL --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 1f927d0..79b0ee5 100644 --- a/action.yml +++ b/action.yml @@ -155,7 +155,7 @@ runs: if: ${{ steps.gruntwork_context.outputs.terragrunt_command == 'apply' }} env: ACTION_PATH: ${{ github.action_path }} - MERGED_PR_NUMBER: ${{ steps.get_pr_number.outputs.pr_number }} + MERGED_PR_URL: https://github.com/${{ github.repository }}/pull/${{ steps.get_pr_number.outputs.pr_number }} CREATED_PR_URL: ${{ steps.create_pr.outputs.pull-request-url }} GH_TOKEN: ${{ inputs.INFRA_ROOT_WRITE_TOKEN }} run: | @@ -166,7 +166,7 @@ runs: cat step-summary.md >> "$GITHUB_STEP_SUMMARY" - gh pr comment "$MERGED_PR_NUMBER" \ + gh pr comment "$MERGED_PR_URL" \ -F step-summary.md rm -f step-summary.md From 8759f36f4befc052d09fe7b3922cb6a434498e1a Mon Sep 17 00:00:00 2001 From: Yousif Akbar <11247449+yhakbar@users.noreply.github.com> Date: Mon, 13 May 2024 19:47:04 -0400 Subject: [PATCH 4/4] Updating copy for the step summary --- templates/step-summary/step-summary.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/step-summary/step-summary.md b/templates/step-summary/step-summary.md index 47ee978..22daae3 100644 --- a/templates/step-summary/step-summary.md +++ b/templates/step-summary/step-summary.md @@ -1,7 +1,7 @@ -### Baseline Pull Request +### Baseline Pull Request 🚧 -Now that you've created your account, you're ready to review and merge the baseline pull request. +Account provisioning complete! 🎉 -This is the pull request that contains the initial resources you need in a new account to have it ready for use. +A baseline pull request has been created to provision the initial resources you need in a new account to have it ready for production workloads. To see the pull request, click [here]({{ .PullRequestURL }}).