Skip to content
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

Pipelines v3 #83

Merged
merged 26 commits into from
Oct 8, 2024
Merged

Pipelines v3 #83

merged 26 commits into from
Oct 8, 2024

Conversation

ZachGoldberg
Copy link
Contributor

@ZachGoldberg ZachGoldberg commented Aug 29, 2024

🎈 Gruntwork Pipelines v3.0.0 Release Notes

Pipelines version 3 introduces several new features which include a number of breaking changes. The migration guide below should take less than 5 minutes for most teams to complete, but please do make sure to follow it closely. We're providing a checklist here to help teams ensure that steps are not skipped.

  • Install and configure the Gruntwork.io GitHub App
    • (Alternative) Add actions:read permission to PIPELINES_READ_TOKEN
    • (Alternative) (Enterprise Only) Add PR_CREATE_TOKEN to delegated repository workflows
  • Update to Terragrunt v0.67.16 or later
  • (If necessary) Add new actions to GitHub Organization allow list settings
  • (Enterprise Only) Install and activate Drift Detection

Migration Guide

Install and configure the Gruntwork.io GitHub App

Pipelines now uses the Gruntwork.io GitHub App for workflow permissions, which simplifies permission management. Follow the GitHub App Installation Instructions to install the Gruntwork.io GitHub App and add your infrastructure-live-root repository to your account.

Using the Gruntwork.io GitHub App is recommended and provides full feature support for pipelines workflows. Alternatively, if you do not wish to install the Gruntwork.io GitHub App you can modify your existing workflows to continue using GitHub secrets, although some features will not be available. Read more about App only features here.

Alternative steps

  1. Add actions: read permissions

Customers explicitly list permissions that Gruntwork Pipelines workflows has by default in the pipelines workflow files in .github/workflows inside their infrastructure repositories. Pipelines v3 now requires actions: read permissions in order to introspect its own runs and provide more helpful logging capabilities.

Customers should make the one-line change to add the actions: read permission in the following files in every repository that uses Gruntwork pipelines (including root, access control and delegated repos). Note, most repositories will have only 1 or two of these workflow files, in which case update what is present and don't worry about the others.

  • .github/workflows/pipelines.yml
  • .github/workflows/pipelines-drift-detection.yml
  • .github/workflows/pipelines-root.yml
  • .github/workflows/pipelines-unlock.yml

Old Permissions

permissions:
  id-token: write
  contents: write
  pull-requests: write

New Permissions

permissions:
  id-token: write
  contents: write
  pull-requests: write
  actions: read
  1. (Enterprise only) Add PR_CREATE_TOKEN to delegated repository workflows.

Delegated repositories that are not using the Gruntwork.io GitHub App will need to add PR_CREATE_TOKEN: ${{ github.token }} to the secrets in their workflow files:

Old Secrets

secrets:
  PIPELINES_READ_TOKEN: ${{ secrets.PIPELINES_READ_TOKEN }}

New Secrets

secrets:
  PIPELINES_READ_TOKEN: ${{ secrets.PIPELINES_READ_TOKEN }}
  PR_CREATE_TOKEN: ${{ github.token }}

Update to Terragrunt v0.67.16

The latest pipelines works best with the latest version of Terragrunt. Recent versions of Terragrunt have much improved logging, performance and correctness improvements in run-all scenarios with pipelines.

Allowlist Actions

This is only for customers who only allow GitHub actions to run if they are on an explicit allowlist

New actions to add

  • gruntwork-io/pipelines-credentials
  • gruntwork-io/pipelines-actions/.github/actions/pipelines-drift-detection-consolidate-jobs
  • gruntwork-io/pipelines-actions/.github/actions/pipelines-drift-detection-determine-units
  • gruntwork-io/pipelines-actions/.github/actions/pipelines-drift-detection-determine-drift
  • gruntwork-io/pipelines-actions/.github/actions/pipelines-new-pr-action
  • gruntwork-io/pipelines-actions/.github/actions/pipelines-get-job-logs-url

(Enterprise Only) Install and activate Drift Detection

Pipelines Drift Detection can be installed in your repositories by adding a new workflow file:
  1. Create a new file at .github/workflows/pipelines-drift-detection.yml
  2. Add the following content to the file
name: Pipelines Drift Detection
run-name: "[GWP]: Pipelines Drift Detection"
on:
  # Uncomment to enable scheduled Drift Detection
  # schedule:
  #  - cron: '15 12 * * 1'
  workflow_dispatch:
    inputs:
      path:
        description: (Optional) Path to filter units e.g. "./management/*"
        type: string
      branch-name:
        description: (Optional) branch name to open Drift Detection PRs with
        default: drift-detection
        type: string
permissions:
  id-token: write

jobs:
  GruntworkPipelines:
    uses: gruntwork-io/pipelines-workflows/.github/workflows/pipelines-drift-detection.yml@v3
    with:
      path: ${{ inputs.path }}
      branch-name: ${{ inputs.branch-name }}

New Features

ZachGoldberg and others added 3 commits August 29, 2024 08:28
…epos (#69)

* chore: start work on dev-378

* chore: change the definition of post-provision new account to be more narrowly tailored to creating the new account, not the PR

* chore: move around some values

* chore: wire up data flows

* chor: update for api changes

* chore: more wiring cleanups
* Update pipelines-root.yml

* Update pipelines-root.yml

* debugging

* Update pipelines-root.yml

* JOB_NAME

* add job_id

* fix missing bracket

* fix

* Run logs url action

* Use 2024-07-19_get-job-id actions

* Add actions: read permission

* permissions

* pass var into next step

* permissions

* fix input

* Dynamic step name

* typo

* test syntax

* test syntax

* colons are broken

* try other quoting

* Add get logs url to other jobs

---------

Co-authored-by: Zach Goldberg <[email protected]>
* WIP add drift detection

* Fix broken if statement

* Pass root as working directory to bootstrap

* Fix exclude root dir from run-all plan

* Fix git change detection

* Working dir for later steps

* Add parallelism limit 6

* Use 0.26.0-rc4. Remove paralllelism limit

* Fix role used for run-all plan

* feat: Adding cross runner cache persistence

* fix whitespace

* Fix missing GH_TOKEN

* Use -n for git status check

* Pipelines CLI v0.26.1

* Fix missing author for create pr

* Pipelines CLI v0.26.2-rc1

* Drift detection 2.0

* Fix command

* GH_TOKEN

* MACHINE_USER_NAME

* Use org repo admin for pr creation

* Add org admin token

* Allow erroring modules. Always cache providers

* Cache auth on disk. Only run first 10.

* Pipelines CLI v0.28.0-rc2

* Pipelines CLI v0.28.0-rc3

* Switch to just plan

* mkdir planfolder

* fix plan folder

* fix plan folder for parse plans

* Pipelines CLI v0.28.0-rc4

* Pipelines CLI v0.28.0-rc5

* Matrixed drift detection jobs

* Inline repo dir

* Fix

* Fix typo

* debug mktemp missing

* fix path var

* dont override path

* pathing

* Update pipelines-drift-detection.yml

* Update pipelines-root.yml

* fix json escape string

* fix array slicing

* fix json escaping

* property quotes

* Add first pass pr body content

* Fix missing pipelines actions

* avoid backtick expansion

* avoid backtick expansion

* echo pr body

* move arg

* bash escape newline

* try other escape

* Use INFRA_ROOT_WRITE_TOKEN

* Use INFRA_ROOT_WRITE_TOKEN

* Add branch link, switch back to drift-detection branch

* Actions @ main

* actions @ main

* Add error detection

* tee to file

* EOF

* multiline github output

* more newlines

* fix job url, path

* debugging

* debugging

* debugging

* debugging

* debugging

* debugging

* add log url link to top of pr body

* remove debug limit of 10 units

* Add step summary

* Fix json output

* try without cred caching

* try without color removal

* restore color removal, remove echos

* Increase line height of drifted items

* Remove debug limit

* Reset changes to other workflows

* Use matching pipelines versions

* Use action for determine

* Pipelines CLI v0.28.0

* Extract drift detection

* Pass args

* typo

* Pass JOB_NAME and STEP_NAME through

* Use merged determine units

* Var rename. Remove terraform syntax highlight

* Test sort units fix

* consolidate jobs action. rename secret

* Add branch_name input

* Fix actions version

* Fix actions version

* Use merged action

* Update pipelines-drift-detection.yml

---------

Co-authored-by: Yousif Akbar <[email protected]>
Co-authored-by: Oreoluwa Agunbiade <[email protected]>
@ZachGoldberg ZachGoldberg changed the title Pipelines v3 Release Candidate Testing Pipelines v3 Release Candidate Aug 29, 2024
@ZachGoldberg ZachGoldberg added the breaking-change Changes that require a major version increment label Aug 29, 2024
Resonance1584 and others added 9 commits September 17, 2024 15:04
* Use actions@2024-08-27_gruntcon_githubapp

* Use [email protected]

* Use pipelines-credentials for downloading actions

* uses format

* Update pipelines-root.yml

* Fix correctly use outputs

* typo

* Try concatenate env

* Try github var

* Pass tokens to execute

* Fix typo

* debug cloning

* chars

* interp

* less args

* remove debugging

* add new tokens to preflight

* rename token

* chore: baseline needs both tokens

* chore: use the new tokens everywhere

* chore: fix token thing

* Fetch infra root write and org admin, pass to preflight

* Switch out admin tokens in root

* Disable provisioning temporarily

* Fix read token ref

* Update unlock to use github app tokens

* Bump pipelines CLI to v0.29.0-rc2

* Use top level env GH_TOKEN

* Use github app in delegated workflow

* Bump pipelines CLI to v0.29.0-rc3

* Try rc3

* Try v0.28.2

* Trace log

* v0.28.3-rc2

* v0.28.3-rc3

* v0.28.3-rc5

* v0.29.0-rc5

* fix: Set `api_base_url`

* fix: Use `gruntwork-io` for `pipelines-credentials`

* feat: Adding dynamicity to API URL

* Use customer org token

* DEV-519 Integerate drift detection with GitHub App (#86)

* Integrate app

* Add org read token

* Add create pr token

* Make secrets not required

* Dynamic api_base_url

* Use moved action

---------

Co-authored-by: Zach Goldberg <[email protected]>
Co-authored-by: Yousif Akbar <[email protected]>
.github/workflows/pipelines-drift-detection.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-drift-detection.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-drift-detection.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-drift-detection.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-drift-detection.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-root.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-root.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-root.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-unlock.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-drift-detection.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-drift-detection.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-root.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-root.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-unlock.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines-unlock.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines.yml Outdated Show resolved Hide resolved
.github/workflows/pipelines.yml Outdated Show resolved Hide resolved
oredavids
oredavids previously approved these changes Oct 8, 2024
inputs:
# This field can be overriden to customize the runner used for pipelines
# workflows.
#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation should be on the runner input. i.e move the path input

with:
PIPELINES_CUSTOMER_ORG_READ_TOKEN: ${{ steps.pipelines-customer-org-read-token.outputs.PIPELINES_TOKEN }}
job_name: ${{ env.JOB_NAME }}
step_name_prefix: "${{ steps.gruntwork_context.outputs.action == 'TERRAGRUNT_EXECUTE' && '[TerragruntExecute]:\ Authenticate with AWS and then Invoke Terragrunt' || (steps.gruntwork_context.outputs.action == 'BASELINE_ACCOUNT' && 'Run core accounts baselines' || '[ProvisionAccount]:\ Provision New Account') }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: This should be refactored out at some point. It's hard how this resolves on first inspection.

@Resonance1584 Resonance1584 changed the title Pipelines v3 Release Candidate Pipelines v3 Oct 8, 2024
@Resonance1584 Resonance1584 merged commit df60c06 into main Oct 8, 2024
1 of 2 checks passed
@Resonance1584 Resonance1584 deleted the v3-rc1 branch October 8, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Changes that require a major version increment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants