generated from cloudposse-github-actions/typescript-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Use GitOps Configuration File #15
Merged
Merged
Changes from 21 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
8a1920b
Incupsulate configs
goruha 3f438b0
Incupsulate configs
goruha 5c84dc8
Incupsulate configs
goruha 7b990e9
Incupsulate configs
goruha 8b6fc68
Incupsulate configs
goruha a8dace2
Incupsulate configs
goruha 9d9b1b7
Incupsulate configs
goruha 0983bd0
Incupsulate configs
goruha 1a4eb7b
Incupsulate configs
goruha 3cbcb63
Incupsulate configs
goruha b845864
Incupsulate configs
goruha b6bb80d
Incupsulate configs
goruha 7f36807
Incupsulate configs
goruha 97736d0
Incupsulate configs
goruha 9a98c48
Incupsulate configs
goruha c0ca40f
Incupsulate configs
goruha a44b896
Incupsulate configs
goruha a0f6fe1
Use cloudposse action config
goruha 2cac00d
Use extended matrix GHA
goruha 8a1573f
Update README
goruha cc9475a
Update README
goruha ab834c0
Apply suggestions from code review
goruha 4e47d34
Update README
goruha f9ca38a
Update action.yml
goruha a98b44e
Update README
goruha fa50260
Update README
goruha 18e0fd7
Apply suggestions from code review
goruha bc4ddfe
Update README.yaml
goruha 5188782
Update README.yaml
goruha 9b7acb9
Update README
goruha 5996298
Fix README
goruha 9620610
Added README
goruha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,15 @@ | ||
name: Feature branch | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [ main ] | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.ref }} | ||
fetch-depth: 1 | ||
|
||
- uses: cloudposse/[email protected] | ||
with: | ||
atmos-version: "latest" | ||
|
||
- uses: dcarbone/[email protected] | ||
with: | ||
version: "1.6" | ||
|
||
- name: Run Tests | ||
run: ./test/run.sh | ||
perform: | ||
uses: cloudposse/github-actions-workflows-github-action-composite/.github/workflows/feature-branch.yml@main | ||
with: | ||
organization: "${{ github.event.repository.owner.login }}" | ||
repository: "${{ github.event.repository.name }}" | ||
ref: "${{ github.event.pull_request.head.ref }}" | ||
secrets: | ||
github-private-actions-pat: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Main branch | ||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
perform: | ||
uses: cloudposse/github-actions-workflows-github-action-composite/.github/workflows/main-branch.yml@main | ||
with: | ||
organization: "${{ github.event.repository.owner.login }}" | ||
repository: "${{ github.event.repository.name }}" | ||
secrets: | ||
github-private-actions-pat: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Test select components with 2 levels of nested matrices | ||
on: | ||
# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered | ||
# # | ||
# # Added pull_request to register workflow from the PR. | ||
# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo | ||
# pull_request: {} | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup | ||
run: echo "Do setup" | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
needs: [setup] | ||
continue-on-error: true | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: ./ | ||
id: current | ||
with: | ||
atmos-gitops-config-path: "./tests/atmos-gitops.yaml" | ||
select-filter: '.settings.github.actions_enabled // false' | ||
nested-matrices-count: '2' | ||
|
||
outputs: | ||
selected-components: "${{ steps.current.outputs.selected-components }}" | ||
matrix: "${{ steps.current.outputs.matrix }}" | ||
|
||
assert: | ||
runs-on: ubuntu-latest | ||
needs: [test] | ||
steps: | ||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: '[{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]' | ||
actual: "${{ needs.test.outputs.selected-components }}" | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: '{"include":[' | ||
actual: "${{ needs.test.outputs.matrix }}" | ||
comparison: contains | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: '{"include":[{"name":"core-auto","items":"{\"include\":[{\"component\":\"test-2\",\"stack\":\"core-ue2-auto\",\"stack_slug\":\"core-ue2-auto-test-2\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"component\":\"test-4\",\"stack\":\"plat-ue2-dev\",\"stack_slug\":\"plat-ue2-dev-test-4\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"component\":\"test-5\",\"stack\":\"plat-ue2-sandbox\",\"stack_slug\":\"plat-ue2-sandbox-test-5\"}]}"}]}' | ||
actual: "${{ needs.test.outputs.matrix }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Test select components with 3 levels of nested matrices | ||
on: | ||
# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered | ||
# # | ||
# # Added pull_request to register workflow from the PR. | ||
# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo | ||
# pull_request: {} | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup | ||
run: echo "Do setup" | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
needs: [setup] | ||
continue-on-error: true | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- uses: ./ | ||
id: current | ||
with: | ||
atmos-gitops-config-path: "./tests/atmos-gitops.yaml" | ||
select-filter: '.settings.github.actions_enabled // false' | ||
nested-matrices-count: '3' | ||
|
||
outputs: | ||
selected-components: "${{ steps.current.outputs.selected-components }}" | ||
matrix: "${{ steps.current.outputs.matrix }}" | ||
|
||
assert: | ||
runs-on: ubuntu-latest | ||
needs: [test] | ||
steps: | ||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: '[{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]' | ||
actual: "${{ needs.test.outputs.selected-components }}" | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: '{"include":[' | ||
actual: "${{ needs.test.outputs.matrix }}" | ||
comparison: contains | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: '{"include":[{"name":"core-auto","items":"{\"include\":[{\"name\":\"core-ue2-auto-test-2 - core-ue2-auto-test-2\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-2\\\",\\\"stack\\\":\\\"core-ue2-auto\\\",\\\"stack_slug\\\":\\\"core-ue2-auto-test-2\\\"}]}\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"name\":\"plat-ue2-dev-test-4 - plat-ue2-dev-test-4\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-4\\\",\\\"stack\\\":\\\"plat-ue2-dev\\\",\\\"stack_slug\\\":\\\"plat-ue2-dev-test-4\\\"}]}\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"name\":\"plat-ue2-sandbox-test-5 - plat-ue2-sandbox-test-5\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-5\\\",\\\"stack\\\":\\\"plat-ue2-sandbox\\\",\\\"stack_slug\\\":\\\"plat-ue2-sandbox-test-5\\\"}]}\"}]}"}]}' | ||
actual: "${{ needs.test.outputs.matrix }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Test select components | ||
on: | ||
# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered | ||
# # | ||
# # Added pull_request to register workflow from the PR. | ||
# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo | ||
# pull_request: {} | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup | ||
run: echo "Do setup" | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
needs: [setup] | ||
continue-on-error: true | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- uses: ./ | ||
id: current | ||
with: | ||
atmos-gitops-config-path: "./tests/atmos-gitops.yaml" | ||
|
||
outputs: | ||
selected-components: "${{ steps.current.outputs.selected-components }}" | ||
matrix: "${{ steps.current.outputs.matrix }}" | ||
|
||
assert: | ||
runs-on: ubuntu-latest | ||
needs: [test] | ||
steps: | ||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: '[{"component":"test-1","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-1"},{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-3","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-3"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]' | ||
actual: "${{ needs.test.outputs.selected-components }}" | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: '{"include":[' | ||
actual: "${{ needs.test.outputs.matrix }}" | ||
comparison: contains | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: '{"include":[{"name":"core-auto","items":"{\"include\":[{\"component\":\"test-1\",\"stack\":\"core-ue2-auto\",\"stack_slug\":\"core-ue2-auto-test-1\"},{\"component\":\"test-2\",\"stack\":\"core-ue2-auto\",\"stack_slug\":\"core-ue2-auto-test-2\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"component\":\"test-3\",\"stack\":\"plat-ue2-dev\",\"stack_slug\":\"plat-ue2-dev-test-3\"},{\"component\":\"test-4\",\"stack\":\"plat-ue2-dev\",\"stack_slug\":\"plat-ue2-dev-test-4\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"component\":\"test-5\",\"stack\":\"plat-ue2-sandbox\",\"stack_slug\":\"plat-ue2-sandbox-test-5\"}]}"}]}' | ||
actual: "${{ needs.test.outputs.matrix }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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`. | ||||||||||||||||||
goruha marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
The config should have the following structure: | ||||||||||||||||||
goruha marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
|
||||||||||||||||||
```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("-") | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
goruha marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
### 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. | ||||||||||||||||||
|
@@ -97,6 +117,42 @@ usage: | | |||||||||||||||||
echo "${{ matrix.stack_slug }}" | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
### Migrating from `v0` to `v1` | ||||||||||||||||||
|
||||||||||||||||||
goruha marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
`v1` replace `jq-query` input with `selected-filter` variable and simplify the query. | ||||||||||||||||||
goruha marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
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` | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
goruha marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
|
||||||||||||||||||
| name | | ||||||||||||||||||
|--------------------------| | ||||||||||||||||||
| `atmos-version` | | ||||||||||||||||||
| `atmos-config-path` | | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
If you want the same behavior in `v1` as in`v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. | ||||||||||||||||||
goruha marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
|
||||||||||||||||||
```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: | ||||||||||||||||||
|
@@ -105,4 +161,6 @@ contributors: | |||||||||||||||||
- name: "Erik Osterman" | ||||||||||||||||||
github: "osterman" | ||||||||||||||||||
- name: "Daniel Miller" | ||||||||||||||||||
github: "milldr" | ||||||||||||||||||
github: "milldr" | ||||||||||||||||||
- name: "Igor Rodionov" | ||||||||||||||||||
github: "goruha" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebuild with latest build-harness. this is using an older README template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@milldr done