generated from cloudposse-github-actions/typescript-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## what * Use a configuration file instead of passing all parameters as inputs ## why * Makes it easier in reusable workflows to reuse actions without needing to edit workflows themselves * Separate business logic from configuration
- Loading branch information
Showing
20 changed files
with
480 additions
and
213 deletions.
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 }}" |
Oops, something went wrong.