From 7f6abe4db1e69f8ae4e1f35d5bc2d008205e2c80 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 15 Feb 2024 01:29:08 +0100 Subject: [PATCH 01/10] Move configs to atmos.yaml --- .github/workflows/test-matrix-2-levels.yml | 2 +- .github/workflows/test-matrix-3-levels.yml | 2 +- .github/workflows/test-positive.yml | 2 +- atmos.yaml | 69 ---------------------- tests/atmos-gitops.yaml | 11 ---- tests/atmos.yaml | 17 ++++++ 6 files changed, 20 insertions(+), 83 deletions(-) delete mode 100644 atmos.yaml delete mode 100644 tests/atmos-gitops.yaml diff --git a/.github/workflows/test-matrix-2-levels.yml b/.github/workflows/test-matrix-2-levels.yml index 1e2ca0b..d53eda9 100644 --- a/.github/workflows/test-matrix-2-levels.yml +++ b/.github/workflows/test-matrix-2-levels.yml @@ -24,7 +24,7 @@ jobs: - uses: ./ id: current with: - atmos-gitops-config-path: "./tests/atmos-gitops.yaml" + atmos-config-path: "./tests" select-filter: '.settings.github.actions_enabled // false' nested-matrices-count: '2' diff --git a/.github/workflows/test-matrix-3-levels.yml b/.github/workflows/test-matrix-3-levels.yml index b68cca5..971ebcc 100644 --- a/.github/workflows/test-matrix-3-levels.yml +++ b/.github/workflows/test-matrix-3-levels.yml @@ -25,7 +25,7 @@ jobs: - uses: ./ id: current with: - atmos-gitops-config-path: "./tests/atmos-gitops.yaml" + atmos-config-path: "./tests" select-filter: '.settings.github.actions_enabled // false' nested-matrices-count: '3' diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml index 514bea0..e92c50d 100644 --- a/.github/workflows/test-positive.yml +++ b/.github/workflows/test-positive.yml @@ -25,7 +25,7 @@ jobs: - uses: ./ id: current with: - atmos-gitops-config-path: "./tests/atmos-gitops.yaml" + atmos-config-path: "./tests" outputs: selected-components: "${{ steps.current.outputs.selected-components }}" diff --git a/atmos.yaml b/atmos.yaml deleted file mode 100644 index d8fa3e7..0000000 --- a/atmos.yaml +++ /dev/null @@ -1,69 +0,0 @@ -# CLI config is loaded from the following locations (from lowest to highest priority): -# system dir (`/usr/local/etc/atmos` on Linux, `%LOCALAPPDATA%/atmos` on Windows) -# home dir (~/.atmos) -# current directory -# ENV vars -# Command-line arguments -# -# It supports POSIX-style Globs for file names/paths (double-star `**` is supported) -# https://en.wikipedia.org/wiki/Glob_(programming) - -# Base path for components, stacks and workflows configurations. -# Can also be set using `ATMOS_BASE_PATH` ENV var, or `--base-path` command-line argument. -# Supports both absolute and relative paths. -# If not provided or is an empty string, `components.terraform.base_path`, `components.helmfile.base_path`, `stacks.base_path` and `workflows.base_path` -# are independent settings (supporting both absolute and relative paths). -# If `base_path` is provided, `components.terraform.base_path`, `components.helmfile.base_path`, `stacks.base_path` and `workflows.base_path` -# are considered paths relative to `base_path`. -base_path: "" - -components: - terraform: - # Can also be set using `ATMOS_COMPONENTS_TERRAFORM_BASE_PATH` ENV var, or `--terraform-dir` command-line argument - # Supports both absolute and relative paths - base_path: "components/terraform" - # Can also be set using `ATMOS_COMPONENTS_TERRAFORM_APPLY_AUTO_APPROVE` ENV var - apply_auto_approve: false - # Can also be set using `ATMOS_COMPONENTS_TERRAFORM_DEPLOY_RUN_INIT` ENV var, or `--deploy-run-init` command-line argument - deploy_run_init: true - # Can also be set using `ATMOS_COMPONENTS_TERRAFORM_INIT_RUN_RECONFIGURE` ENV var, or `--init-run-reconfigure` command-line argument - init_run_reconfigure: true - # Can also be set using `ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_BACKEND_FILE` ENV var, or `--auto-generate-backend-file` command-line argument - auto_generate_backend_file: true - helmfile: - # Can also be set using `ATMOS_COMPONENTS_HELMFILE_BASE_PATH` ENV var, or `--helmfile-dir` command-line argument - # Supports both absolute and relative paths - base_path: "components/helmfile" - # Can also be set using `ATMOS_COMPONENTS_HELMFILE_KUBECONFIG_PATH` ENV var - kubeconfig_path: "/conf/.kube/" - # Can also be set using `ATMOS_COMPONENTS_HELMFILE_HELM_AWS_PROFILE_PATTERN` ENV var - helm_aws_profile_pattern: "{namespace}-{tenant}-gbl-{stage}-helm" - # Can also be set using `ATMOS_COMPONENTS_HELMFILE_CLUSTER_NAME_PATTERN` ENV var - cluster_name_pattern: "{namespace}-{tenant}-{environment}-{stage}-eks-cluster" - -stacks: - # Can also be set using `ATMOS_STACKS_BASE_PATH` ENV var, or `--config-dir` and `--stacks-dir` command-line arguments - # Supports both absolute and relative paths - base_path: "stacks" - # Can also be set using `ATMOS_STACKS_INCLUDED_PATHS` ENV var (comma-separated values string) - # Since we are distinguishing stacks based on namespace, and namespace is not part - # of the stack name, we have to set `included_paths` via the ENV var in the Dockerfile - included_paths: - - "orgs/**/*" - # Can also be set using `ATMOS_STACKS_EXCLUDED_PATHS` ENV var (comma-separated values string) - excluded_paths: - - "**/_defaults.yaml" - # exclude workflows directory if otherwise included in `included_paths` above - # - "workflows/**/*" - - # Can also be set using `ATMOS_STACKS_NAME_PATTERN` ENV var - name_pattern: "{tenant}-{environment}-{stage}" - -workflows: - # Can also be set using `ATMOS_WORKFLOWS_BASE_PATH` ENV var, or `--workflows-dir` command-line arguments - # Supports both absolute and relative paths - base_path: "stacks/workflows" - -logs: - verbose: false - colors: true diff --git a/tests/atmos-gitops.yaml b/tests/atmos-gitops.yaml deleted file mode 100644 index db46a85..0000000 --- a/tests/atmos-gitops.yaml +++ /dev/null @@ -1,11 +0,0 @@ -atmos-version: 1.45.3 -atmos-config-path: ./tests/ -terraform-state-bucket: cptest-core-ue2-auto-gitops -terraform-state-table: cptest-core-ue2-auto-gitops -terraform-state-role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha -terraform-plan-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops -terraform-apply-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops -terraform-version: 1.5.2 -aws-region: us-east-2 -sort-by: .stack_slug -group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") diff --git a/tests/atmos.yaml b/tests/atmos.yaml index 8ee70cf..b8a9bcd 100644 --- a/tests/atmos.yaml +++ b/tests/atmos.yaml @@ -59,6 +59,23 @@ stacks: # Can also be set using `ATMOS_STACKS_NAME_PATTERN` ENV var name_pattern: "{tenant}-{environment}-{stage}" +integrations: + github: + gitops: + terraform-version: 1.5.2 + infracost-enabled: false + storage: + region: us-east-2 + bucket: cptest-core-ue2-auto-gitops + table: cptest-core-ue2-auto-gitops-plan-storage + role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha + role: + plan: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + apply: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + matrix: + sort-by: .stack_slug + group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") + workflows: # Can also be set using `ATMOS_WORKFLOWS_BASE_PATH` ENV var, or `--workflows-dir` command-line arguments # Supports both absolute and relative paths From 67be822d7ac693880e1c44c82f7a77d1b8c6a138 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 15 Feb 2024 01:33:56 +0100 Subject: [PATCH 02/10] Move configs to atmos.yaml --- action.yml | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/action.yml b/action.yml index f42ae74..e92891d 100644 --- a/action.yml +++ b/action.yml @@ -13,10 +13,13 @@ inputs: description: The head ref to checkout. If not provided, the head default branch is used. required: false default: ${{ github.sha }} - atmos-gitops-config-path: - description: The path to the atmos-gitops.yaml file + atmos-version: + description: The version of atmos to install required: false - default: ./.github/config/atmos-gitops.yaml + default: ">= 1.63.0" + atmos-config-path: + description: The path to the atmos.yaml file + required: true jq-version: description: The version of jq to install if install-jq is true required: false @@ -47,34 +50,28 @@ runs: with: ref: ${{ inputs.head-ref }} - - name: Read Atmos GitOps config - ## We have to reference cloudposse fork of https://github.com/blablacar/action-config-levels - ## before https://github.com/blablacar/action-config-levels/pull/16 would be merged - uses: cloudposse/github-action-config-levels@nodejs20 - id: config - with: - output_properties: true - patterns: | - - ${{ inputs.atmos-gitops-config-path }} - - - name: Install Terraform - uses: hashicorp/setup-terraform@v2 + - name: Install JQ + uses: dcarbone/install-jq-action@v1.0.1 with: - terraform_version: ${{ steps.config.outputs.terraform-version }} - terraform_wrapper: false + version: ${{ inputs.jq-version }} - - name: Install Atmos + - if: ${{ inputs.install-atmos == 'true' }} uses: cloudposse/github-action-setup-atmos@v1 - env: - ATMOS_CLI_CONFIG_PATH: ${{inputs.atmos-config-path}} with: - atmos-version: ${{ steps.config.outputs.atmos-version }} + atmos-version: ${{ inputs.atmos-version }} install-wrapper: false - - name: Install JQ - uses: dcarbone/install-jq-action@v1.0.1 - with: - version: ${{ inputs.jq-version }} + - name: Set vars + shell: bash + run: |- + echo "ATMOS_CLI_CONFIG_PATH=$(realpath ${{ inputs.atmos-config-path }})" >> $GITHUB_ENV + + - name: config + shell: bash + id: config + run: |- + echo "group-by=$(atmos describe config -f json | jq -r '.integrations.github.gitops.matrix["group-by"]')" >> $GITHUB_OUTPUT + echo "sort-by=$(atmos describe config -f json | jq -r '.integrations.github.gitops.matrix["sort-by"]')" >> $GITHUB_OUTPUT - name: Filter Components id: selected-components From 47bad23bc4225061f3b3b6552f2d0b154b3afdf0 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 15 Feb 2024 01:36:29 +0100 Subject: [PATCH 03/10] Move configs to atmos.yaml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e92891d..76bd2f1 100644 --- a/action.yml +++ b/action.yml @@ -55,7 +55,7 @@ runs: with: version: ${{ inputs.jq-version }} - - if: ${{ inputs.install-atmos == 'true' }} + - name: Install Atmos uses: cloudposse/github-action-setup-atmos@v1 with: atmos-version: ${{ inputs.atmos-version }} From 31fd98994bf3c536d9e67d85fac36ee7ede6daaf Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 15 Feb 2024 01:41:57 +0100 Subject: [PATCH 04/10] Move configs to atmos.yaml --- action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yml b/action.yml index 76bd2f1..4441e94 100644 --- a/action.yml +++ b/action.yml @@ -77,7 +77,6 @@ runs: id: selected-components shell: bash env: - ATMOS_CLI_CONFIG_PATH: ${{ steps.config.outputs.atmos-config-path }} JQUERY: | with_entries(.value |= (.components.terraform)) | ## Deal with components type of terraform map_values(map_values(select(${{ inputs.select-filter }}))) | ## Filter components by enabled github actions From 2f492f6158b89dd70529bedfa06bd5e1ad47e9d1 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 15 Feb 2024 01:58:06 +0100 Subject: [PATCH 05/10] Update README --- README.md | 262 ++++++++++++++++++++++++++++-------------- README.yaml | 138 +++++++++++++++++++--- docs/github-action.md | 3 +- 3 files changed, 296 insertions(+), 107 deletions(-) diff --git a/README.md b/README.md index e3a8bf1..775354a 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,8 @@ - -# github-action-atmos-terraform-select-components - - [![Latest Release](https://img.shields.io/github/release/cloudposse/github-action-atmos-terraform-select-components.svg)](https://github.com/cloudposse/github-action-atmos-terraform-select-components/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) +# github-action-atmos-terraform-select-components +Latest ReleaseSlack Community -[![README Header][readme_header_img]][readme_header_link] - -[![Cloud Posse][logo]](https://cpco.io/homepage) - - [logo]: https://cloudposse.com/logo-300x69.svg - [docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=docs - [website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=website - [github]: https://cpco.io/github?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=github - [jobs]: https://cpco.io/jobs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=jobs - [hire]: https://cpco.io/hire?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=hire - [slack]: https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=slack - [twitter]: https://cpco.io/twitter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=twitter - [office_hours]: https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=office_hours - [newsletter]: https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=newsletter - [email]: https://cpco.io/email?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=email - [commercial_support]: https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=commercial_support - [we_love_open_source]: https://cpco.io/we-love-open-source?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=we_love_open_source - [terraform_modules]: https://cpco.io/terraform-modules?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=terraform_modules - [readme_header_img]: https://cloudposse.com/readme/header/img - [readme_header_link]: https://cloudposse.com/readme/header/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=readme_header_link - [readme_footer_img]: https://cloudposse.com/readme/footer/img - [readme_footer_link]: https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=readme_footer_link - [readme_commercial_support_img]: https://cloudposse.com/readme/commercial-support/img - [readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=readme_commercial_support_link - [beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/github-action-atmos-terraform-select-components?pixel&cs=github&cm=readme&an=github-action-atmos-terraform-select-components - +Copyright Β© 2017-2024 [Cloud Posse, LLC](https://cpco.io/copyright) + + +README footer + +Beacon diff --git a/README.yaml b/README.yaml index d3f7c78..5120926 100644 --- a/README.yaml +++ b/README.yaml @@ -66,27 +66,31 @@ references: usage: | ### Config - The action expects the atmos gitops configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. + The action expects the atmos configuration file `atmos.yaml` to be present in the repository and contains. The config should have the following structure: ```yaml - atmos-version: 1.45.3 - atmos-config-path: ./rootfs/usr/local/etc/atmos/ - terraform-state-bucket: cptest-core-ue2-auto-gitops - terraform-state-table: cptest-core-ue2-auto-gitops - terraform-state-role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha - terraform-plan-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops - terraform-apply-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops - terraform-version: 1.5.2 - aws-region: us-east-2 - enable-infracost: false - sort-by: .stack_slug - group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") - ``` - + integrations: + github: + gitops: + terraform-version: 1.5.2 + infracost-enabled: false + storage: + region: us-east-2 + bucket: cptest-core-ue2-auto-gitops + table: cptest-core-ue2-auto-gitops-plan-storage + role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha + role: + plan: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + apply: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + matrix: + sort-by: .stack_slug + group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") + ``` + > [!IMPORTANT] - > **Please note!** the `terraform-state-*` parameters refer to the S3 Bucket and corresponding meta storage DynamoDB table used to store the Terraform Plan files, and not the "Terraform State". These parameters will be renamed in a subsequent release. - + > **Please note!** the action works only with `atmos >= 1.63.0`. If you are using `atmos < 1.63.0` please use `v2` of the action. + ### GitHub Actions Workflow Example In following GitHub workflow example first job will filter components that have settings `github.actions_enabled: true` and then in following job `stack_slug` will be printed to stdout. @@ -101,7 +105,7 @@ usage: | steps: - name: Selected Components id: components - uses: cloudposse/github-action-atmos-terraform-select-components@v0 + uses: cloudposse/github-action-atmos-terraform-select-components@v2 with: atmos-config-path: "${{ github.workspace }}/rootfs/usr/local/etc/atmos/" jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' @@ -120,6 +124,104 @@ usage: | echo "${{ matrix.stack_slug }}" ``` + ### Migrating from `v1` to `v2` + + `v2` works only with `atmos >= 1.63.0` + + `v2` drops `install-terraform` input because terraform is not required for affected stacks call + + `v2` drop `atmos-gitops-config-path` input and `./.github/config/atmos-gitops.yaml` config. Now you have to use GitHub actions inputs and `atmos.yaml` to specify that configuration. + + The following configuration fields now moved to GitHub action inputs with the same names + + | name | + |-------------------------| + | `atmos-version` | + | `atmos-config-path` | + + + The following configuration fields are now moved to `atmos.yaml` + + | name | path in `atmos.yaml` | + |--------------------------|-------------------------------------------------| + | `aws-region` | `integrations.github.gitops.storage.region` | + | `terraform-state-bucket` | `integrations.github.gitops.storage.bucket` | + | `terraform-state-table` | `integrations.github.gitops.storage.table` | + | `terraform-state-role` | `integrations.github.gitops.storage.role` | + | `terraform-plan-role` | `integrations.github.gitops.role.plan` | + | `terraform-apply-role` | `integrations.github.gitops.role.apply` | + | `terraform-version` | `integrations.github.gitops.terraform-version` | + | `enable-infracost` | `integrations.github.gitops.infracost-enabled` | + | `sort-by` | `integrations.github.gitops.matrix.sort-by` | + | `group-by` | `integrations.github.gitops.matrix.group-by` | + + + If you want `v2` having the same behaviour as `v1` you should have + + `atmos.yaml` + ```yaml + ... + + integrations: + github: + gitops: + terraform-version: 1.5.2 + infracost-enabled: false + storage: + region: us-east-2 + bucket: cptest-core-ue2-auto-gitops + table: cptest-core-ue2-auto-gitops-plan-storage + role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha + role: + plan: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + apply: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + matrix: + sort-by: .stack_slug + group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") + + ... + ``` + + `.github/workflows/main.yaml` + ```yaml + - name: Selected Components + id: components + uses: cloudposse/github-action-atmos-terraform-select-components@v2 + with: + atmos-config-path: ./ + jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' + ``` + + same behaviour as + + `./.github/config/atmos-gitops.yaml` + ```yaml + atmos-version: 1.45.3 + atmos-config-path: ./rootfs/usr/local/etc/atmos/ + terraform-state-bucket: cptest-core-ue2-auto-gitops + terraform-state-table: cptest-core-ue2-auto-gitops + terraform-state-role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha + terraform-plan-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + terraform-apply-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + terraform-version: 1.5.2 + aws-region: us-east-2 + enable-infracost: false + sort-by: .stack_slug + group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") + ``` + + `.github/workflows/main.yaml` + ```yaml + - name: Selected Components + id: components + uses: cloudposse/github-action-atmos-terraform-select-components@v1 + with: + atmos-gitops-config-path: ./.github/config/atmos-gitops.yaml + jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' + + ``` + + ### Migrating from `v0` to `v1` 1. `v1` replaces the `jq-query` input parameter with a new parameter called `selected-filter` to simplify the query for end-users. diff --git a/docs/github-action.md b/docs/github-action.md index 78f65a0..e8ccfff 100644 --- a/docs/github-action.md +++ b/docs/github-action.md @@ -4,7 +4,8 @@ | Name | Description | Default | Required | |------|-------------|---------|----------| -| atmos-gitops-config-path | The path to the atmos-gitops.yaml file | ./.github/config/atmos-gitops.yaml | false | +| atmos-config-path | The path to the atmos.yaml file | N/A | true | +| atmos-version | The version of atmos to install | >= 1.63.0 | false | | debug | Enable action debug mode. Default: 'false' | false | false | | head-ref | The head ref to checkout. If not provided, the head default branch is used. | ${{ github.sha }} | false | | jq-version | The version of jq to install if install-jq is true | 1.6 | false | From c6b36d0a0574644748ab6958e9f60e8fd8b62933 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Wed, 21 Feb 2024 21:21:21 +0100 Subject: [PATCH 06/10] Fix readme --- README.md | 4 ++-- README.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 775354a..2012068 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ The following configuration fields are now moved to `atmos.yaml` If you want `v2` having the same behaviour as `v1` you should have -`atmos.yaml` +`./.github/config/atmos-gitops.yaml` ```yaml ... @@ -192,7 +192,7 @@ integrations: id: components uses: cloudposse/github-action-atmos-terraform-select-components@v2 with: - atmos-config-path: ./ + atmos-config-path: ./rootfs/usr/local/etc/atmos/ jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' ``` diff --git a/README.yaml b/README.yaml index 5120926..1888d1a 100644 --- a/README.yaml +++ b/README.yaml @@ -158,7 +158,7 @@ usage: | If you want `v2` having the same behaviour as `v1` you should have - `atmos.yaml` + `./.github/config/atmos-gitops.yaml` ```yaml ... @@ -188,7 +188,7 @@ usage: | id: components uses: cloudposse/github-action-atmos-terraform-select-components@v2 with: - atmos-config-path: ./ + atmos-config-path: ./rootfs/usr/local/etc/atmos/ jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' ``` From d75d46d6612ccdcbf44af29011de18921bcabf3c Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Tue, 5 Mar 2024 14:57:42 +0100 Subject: [PATCH 07/10] Address comments --- README.md | 26 +++++++++++++------------- README.yaml | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 2012068..32acb00 100644 --- a/README.md +++ b/README.md @@ -130,11 +130,11 @@ In following GitHub workflow example first job will filter components that have ### Migrating from `v1` to `v2` -`v2` works only with `atmos >= 1.63.0` +The notable changes in `v2` are: -`v2` drops `install-terraform` input because terraform is not required for affected stacks call - -`v2` drop `atmos-gitops-config-path` input and `./.github/config/atmos-gitops.yaml` config. Now you have to use GitHub actions inputs and `atmos.yaml` to specify that configuration. +- `v2` works only with `atmos >= 1.63.0` +- `v2` drops `install-terraform` input because terraform is not required for affected stacks call +- `v2` drops `atmos-gitops-config-path` input and the `./.github/config/atmos-gitops.yaml` config file. Now you have to use GitHub Actions environment variables to specify the location of the `atmos.yaml`. The following configuration fields now moved to GitHub action inputs with the same names @@ -144,9 +144,9 @@ The following configuration fields now moved to GitHub action inputs with the sa | `atmos-config-path` | -The following configuration fields are now moved to `atmos.yaml` +The following configuration fields moved to the `atmos.yaml` configuration file. -| name | path in `atmos.yaml` | +| name | YAML path in `atmos.yaml` | |--------------------------|-------------------------------------------------| | `aws-region` | `integrations.github.gitops.storage.region` | | `terraform-state-bucket` | `integrations.github.gitops.storage.bucket` | @@ -160,11 +160,11 @@ The following configuration fields are now moved to `atmos.yaml` | `group-by` | `integrations.github.gitops.matrix.group-by` | -If you want `v2` having the same behaviour as `v1` you should have +For example, to migrate from `v1` to `v2`, you should have something similar to the following in your `atmos.yaml`: -`./.github/config/atmos-gitops.yaml` +`./.github/config/atmos.yaml` ```yaml -... +# ... your existing configuration integrations: github: @@ -182,8 +182,6 @@ integrations: matrix: sort-by: .stack_slug group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") - -... ``` `.github/workflows/main.yaml` @@ -196,9 +194,9 @@ integrations: jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' ``` -same behaviour as +This corresponds to the `v1` configuration (deprecated) below. -`./.github/config/atmos-gitops.yaml` +The `v1` configuration file `./.github/config/atmos-gitops.yaml` looked like this: ```yaml atmos-version: 1.45.3 atmos-config-path: ./rootfs/usr/local/etc/atmos/ @@ -214,6 +212,8 @@ sort-by: .stack_slug group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") ``` +And the `v1` GitHub Action Workflow looked like this. + `.github/workflows/main.yaml` ```yaml - name: Selected Components diff --git a/README.yaml b/README.yaml index 1888d1a..a70f435 100644 --- a/README.yaml +++ b/README.yaml @@ -126,11 +126,11 @@ usage: | ### Migrating from `v1` to `v2` - `v2` works only with `atmos >= 1.63.0` + The notable changes in `v2` are: - `v2` drops `install-terraform` input because terraform is not required for affected stacks call - - `v2` drop `atmos-gitops-config-path` input and `./.github/config/atmos-gitops.yaml` config. Now you have to use GitHub actions inputs and `atmos.yaml` to specify that configuration. + - `v2` works only with `atmos >= 1.63.0` + - `v2` drops `install-terraform` input because terraform is not required for affected stacks call + - `v2` drops `atmos-gitops-config-path` input and the `./.github/config/atmos-gitops.yaml` config file. Now you have to use GitHub Actions environment variables to specify the location of the `atmos.yaml`. The following configuration fields now moved to GitHub action inputs with the same names @@ -140,9 +140,9 @@ usage: | | `atmos-config-path` | - The following configuration fields are now moved to `atmos.yaml` + The following configuration fields moved to the `atmos.yaml` configuration file. - | name | path in `atmos.yaml` | + | name | YAML path in `atmos.yaml` | |--------------------------|-------------------------------------------------| | `aws-region` | `integrations.github.gitops.storage.region` | | `terraform-state-bucket` | `integrations.github.gitops.storage.bucket` | @@ -156,11 +156,11 @@ usage: | | `group-by` | `integrations.github.gitops.matrix.group-by` | - If you want `v2` having the same behaviour as `v1` you should have + For example, to migrate from `v1` to `v2`, you should have something similar to the following in your `atmos.yaml`: - `./.github/config/atmos-gitops.yaml` + `./.github/config/atmos.yaml` ```yaml - ... + # ... your existing configuration integrations: github: @@ -178,8 +178,6 @@ usage: | matrix: sort-by: .stack_slug group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") - - ... ``` `.github/workflows/main.yaml` @@ -192,9 +190,9 @@ usage: | jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' ``` - same behaviour as + This corresponds to the `v1` configuration (deprecated) below. - `./.github/config/atmos-gitops.yaml` + The `v1` configuration file `./.github/config/atmos-gitops.yaml` looked like this: ```yaml atmos-version: 1.45.3 atmos-config-path: ./rootfs/usr/local/etc/atmos/ @@ -210,6 +208,8 @@ usage: | group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") ``` + And the `v1` GitHub Action Workflow looked like this. + `.github/workflows/main.yaml` ```yaml - name: Selected Components From 9e8e44c82f3450e832f985f40547d306b7e287d6 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Tue, 5 Mar 2024 15:05:23 +0100 Subject: [PATCH 08/10] Address comments --- README.md | 2 +- README.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 32acb00..6859bfc 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ integrations: ``` > [!IMPORTANT] -> **Please note!** the action works only with `atmos >= 1.63.0`. If you are using `atmos < 1.63.0` please use `v2` of the action. +> **Please note!** This GitHub Action only works with `atmos >= 1.63.0`. If you are using `atmos < 1.63.0` please use `v1` version of this action. ### GitHub Actions Workflow Example diff --git a/README.yaml b/README.yaml index a70f435..20a74a8 100644 --- a/README.yaml +++ b/README.yaml @@ -89,7 +89,7 @@ usage: | ``` > [!IMPORTANT] - > **Please note!** the action works only with `atmos >= 1.63.0`. If you are using `atmos < 1.63.0` please use `v2` of the action. + > **Please note!** This GitHub Action only works with `atmos >= 1.63.0`. If you are using `atmos < 1.63.0` please use `v1` version of this action. ### GitHub Actions Workflow Example From 649f42f5323c9edab5f3ee30df99d350e7324e75 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Tue, 5 Mar 2024 17:22:27 +0100 Subject: [PATCH 09/10] Replace storage with artifact-storage in atmos.yaml config --- README.md | 12 ++++++------ README.yaml | 12 ++++++------ tests/atmos.yaml | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6859bfc..c620883 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ integrations: gitops: terraform-version: 1.5.2 infracost-enabled: false - storage: + artifact-storage: region: us-east-2 bucket: cptest-core-ue2-auto-gitops table: cptest-core-ue2-auto-gitops-plan-storage @@ -148,10 +148,10 @@ The following configuration fields moved to the `atmos.yaml` configuration file. | name | YAML path in `atmos.yaml` | |--------------------------|-------------------------------------------------| -| `aws-region` | `integrations.github.gitops.storage.region` | -| `terraform-state-bucket` | `integrations.github.gitops.storage.bucket` | -| `terraform-state-table` | `integrations.github.gitops.storage.table` | -| `terraform-state-role` | `integrations.github.gitops.storage.role` | +| `aws-region` | `integrations.github.gitops.artifact-storage.region` | +| `terraform-state-bucket` | `integrations.github.gitops.artifact-storage.bucket` | +| `terraform-state-table` | `integrations.github.gitops.artifact-storage.table` | +| `terraform-state-role` | `integrations.github.gitops.artifact-storage.role` | | `terraform-plan-role` | `integrations.github.gitops.role.plan` | | `terraform-apply-role` | `integrations.github.gitops.role.apply` | | `terraform-version` | `integrations.github.gitops.terraform-version` | @@ -171,7 +171,7 @@ integrations: gitops: terraform-version: 1.5.2 infracost-enabled: false - storage: + artifact-storage: region: us-east-2 bucket: cptest-core-ue2-auto-gitops table: cptest-core-ue2-auto-gitops-plan-storage diff --git a/README.yaml b/README.yaml index 20a74a8..55cb62c 100644 --- a/README.yaml +++ b/README.yaml @@ -75,7 +75,7 @@ usage: | gitops: terraform-version: 1.5.2 infracost-enabled: false - storage: + artifact-storage: region: us-east-2 bucket: cptest-core-ue2-auto-gitops table: cptest-core-ue2-auto-gitops-plan-storage @@ -144,10 +144,10 @@ usage: | | name | YAML path in `atmos.yaml` | |--------------------------|-------------------------------------------------| - | `aws-region` | `integrations.github.gitops.storage.region` | - | `terraform-state-bucket` | `integrations.github.gitops.storage.bucket` | - | `terraform-state-table` | `integrations.github.gitops.storage.table` | - | `terraform-state-role` | `integrations.github.gitops.storage.role` | + | `aws-region` | `integrations.github.gitops.artifact-storage.region` | + | `terraform-state-bucket` | `integrations.github.gitops.artifact-storage.bucket` | + | `terraform-state-table` | `integrations.github.gitops.artifact-storage.table` | + | `terraform-state-role` | `integrations.github.gitops.artifact-storage.role` | | `terraform-plan-role` | `integrations.github.gitops.role.plan` | | `terraform-apply-role` | `integrations.github.gitops.role.apply` | | `terraform-version` | `integrations.github.gitops.terraform-version` | @@ -167,7 +167,7 @@ usage: | gitops: terraform-version: 1.5.2 infracost-enabled: false - storage: + artifact-storage: region: us-east-2 bucket: cptest-core-ue2-auto-gitops table: cptest-core-ue2-auto-gitops-plan-storage diff --git a/tests/atmos.yaml b/tests/atmos.yaml index b8a9bcd..860c3f1 100644 --- a/tests/atmos.yaml +++ b/tests/atmos.yaml @@ -64,7 +64,7 @@ integrations: gitops: terraform-version: 1.5.2 infracost-enabled: false - storage: + artifact-storage: region: us-east-2 bucket: cptest-core-ue2-auto-gitops table: cptest-core-ue2-auto-gitops-plan-storage From 5bc76fedbd8a3c6216960400358909656cdc46c9 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Fri, 8 Mar 2024 17:58:53 +0100 Subject: [PATCH 10/10] Address comments --- README.md | 2 +- README.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c620883..526e47e 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Output of this action is a list of basic component information. For example: ### Config -The action expects the atmos configuration file `atmos.yaml` to be present in the repository and contains. +The action expects the atmos configuration file `atmos.yaml` to be present in the repository. The config should have the following structure: ```yaml diff --git a/README.yaml b/README.yaml index 55cb62c..88ea59e 100644 --- a/README.yaml +++ b/README.yaml @@ -66,7 +66,7 @@ references: usage: | ### Config - The action expects the atmos configuration file `atmos.yaml` to be present in the repository and contains. + The action expects the atmos configuration file `atmos.yaml` to be present in the repository. The config should have the following structure: ```yaml