Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
goruha committed Dec 9, 2023
1 parent 2cac00d commit 8a1573f
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 13 deletions.
61 changes: 59 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ Output of this action is a list of basic component information. For example:



### Config

The action expects the atmos gitops configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`.
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("-")
```
### 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.
Expand Down Expand Up @@ -122,6 +142,41 @@ In following GitHub workflow example first job will filter components that have
echo "${{ matrix.stack_slug }}"
```

### Migrate from `v0` to `v1`

`v1` replace `jq-query` input with `selected-filter` variable and simplify the query.
Now you need to specify only part used in select function of `jq-query`.

`v1` moved variables from `inputs` to atmos gitops config path `./.github/config/atmos-gitops.yaml`

| name |
|--------------------------|
| `atmos-version` |
| `atmos-config-path` |


If you want `v1` having the same behaviour as `v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs.

```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
select-filter: '.settings.github.actions_enabled // false'
```

same behaviour as

```yaml
- name: Selected Components
id: components
uses: cloudposse/github-action-atmos-terraform-select-components@v0
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(",")'
```




Expand Down Expand Up @@ -284,8 +339,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
### Contributors

<!-- markdownlint-disable -->
| [![Zinovii Dmytriv][zdmytriv_avatar]][zdmytriv_homepage]<br/>[Zinovii Dmytriv][zdmytriv_homepage] | [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Daniel Miller][milldr_avatar]][milldr_homepage]<br/>[Daniel Miller][milldr_homepage] |
|---|---|---|
| [![Zinovii Dmytriv][zdmytriv_avatar]][zdmytriv_homepage]<br/>[Zinovii Dmytriv][zdmytriv_homepage] | [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Daniel Miller][milldr_avatar]][milldr_homepage]<br/>[Daniel Miller][milldr_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]<br/>[Igor Rodionov][goruha_homepage] |
|---|---|---|---|
<!-- markdownlint-restore -->

[zdmytriv_homepage]: https://github.com/zdmytriv
Expand All @@ -294,6 +349,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
[osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png
[milldr_homepage]: https://github.com/milldr
[milldr_avatar]: https://img.cloudposse.com/150x150/https://github.com/milldr.png
[goruha_homepage]: https://github.com/goruha
[goruha_avatar]: https://img.cloudposse.com/150x150/https://github.com/goruha.png

[![README Footer][readme_footer_img]][readme_footer_link]
[![Beacon][beacon]][website]
Expand Down
60 changes: 59 additions & 1 deletion README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ references:
url: "https://github.com/cloudposse/example-github-action-release-workflow"

usage: |
### Config
The action expects the atmos gitops configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`.
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("-")
```
### 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.
Expand Down Expand Up @@ -97,6 +117,42 @@ usage: |
echo "${{ matrix.stack_slug }}"
```
### Migrate from `v0` to `v1`
`v1` replace `jq-query` input with `selected-filter` variable and simplify the query.
Now you need to specify only part used in select function of `jq-query`.
`v1` moved variables from `inputs` to atmos gitops config path `./.github/config/atmos-gitops.yaml`
| name |
|--------------------------|
| `atmos-version` |
| `atmos-config-path` |
If you want `v1` having the same behaviour as `v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs.
```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
select-filter: '.settings.github.actions_enabled // false'
```
same behaviour as
```yaml
- name: Selected Components
id: components
uses: cloudposse/github-action-atmos-terraform-select-components@v0
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(",")'
```
include:

contributors:
Expand All @@ -105,4 +161,6 @@ contributors:
- name: "Erik Osterman"
github: "osterman"
- name: "Daniel Miller"
github: "milldr"
github: "milldr"
- name: "Igor Rodionov"
github: "goruha"
10 changes: 5 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ runs:
env:
ATMOS_CLI_CONFIG_PATH: ${{ steps.config.outputs.atmos-config-path }}
JQUERY: |
with_entries(.value |= (.components.terraform)) | ## Deal with components type of terraform
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
map_values(select(. != {})) | ## Skip stacks that have 0 selected components
map_values(. | keys) | ## Reduce to component names
with_entries( ## Construct component object
map_values(select(. != {})) | ## Skip stacks that have 0 selected components
map_values(. | keys) | ## Reduce to component names
with_entries( ## Construct component object
.key as $stack |
.value |= map({
"component": .,
"stack": $stack,
"stack_slug": [$stack, .] | join("-")
})
) | map(.) | flatten ## Reduce to flat array
) | map(.) | flatten ## Reduce to flat array
run: |
atmos describe stacks --format json | jq -ce "${JQUERY}" > components.json
Expand Down
9 changes: 4 additions & 5 deletions docs/github-action.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

| Name | Description | Default | Required |
|------|-------------|---------|----------|
| atmos-config-path | The path to the atmos.yaml file | atmos.yaml | false |
| atmos-version | The version of atmos to install if install-atmos is true | latest | false |
| atmos-gitops-config-path | The path to the atmos-gitops.yaml file | ./.github/config/atmos-gitops.yaml | false |
| debug | Enable action debug mode. Default: 'false' | false | false |
| default-branch | The default branch to use for the base ref. | ${{ github.event.repository.default\_branch }} | false |
| jq-query | jq query that will be used to select atmos components | N/A | true |
| 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 |
| terraform-version | The version of terraform to install if install-terraform is true | latest | false |
| nested-matrices-count | Matrices nested levels count (from 1 to 3) | 2 | false |
| select-filter | jq query that will be used to select atmos components | . | false |


## Outputs
Expand Down

0 comments on commit 8a1573f

Please sign in to comment.