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

list-targets: Allow passing multi-line files #247

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions .github/workflows/ci-subaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ jobs:
with:
workdir: ./test/group
-
name: Show matrix
name: Show targets
run: |
echo matrix=${{ steps.gen.outputs.matrix }}
echo targets=${{ steps.gen.outputs.targets }}

list-targets-group-matrix:
runs-on: ubuntu-latest
Expand All @@ -56,6 +56,26 @@ jobs:
workdir: ./test/group-matrix
target: validate
-
name: Show matrix
name: Show targets
run: |
echo matrix=${{ steps.gen.outputs.matrix }}
echo targets=${{ steps.gen.outputs.targets }}

list-targets-multi-files:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Matrix gen
id: gen
uses: ./subaction/list-targets
with:
workdir: ./test/multi-files
files: |
docker-bake.json
docker-bake.hcl
-
name: Show targets
run: |
echo targets=${{ steps.gen.outputs.targets }}
2 changes: 1 addition & 1 deletion subaction/list-targets/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ runs:
with:
script: |
let def;
const files = `${{ inputs.files }}` ? `${{ inputs.files }}`.split(',') : [];
const files = `${{ inputs.files }}` ? `${{ inputs.files }}`.split(/[\r?\n,]+/).filter(Boolean) : [];
const target = `${{ inputs.target }}`;

await core.group(`Validating definition`, async () => {
Expand Down
15 changes: 15 additions & 0 deletions test/multi-files/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
group "default" {
targets = ["t3"]
}

target "t3" {
name = "${item.tag}"
matrix = {
item = t3
}
args = {
VERSION = "${item.version}"
DUMMY_ARG = "${item.arg}"
}
tags = ["${item.tag}"]
}
14 changes: 14 additions & 0 deletions test/multi-files/docker-bake.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"t3": [
{
"version": "v1",
"arg": "v1-value",
"tag": "v1-tag"
},
{
"version": "v2",
"arg": "v2-value",
"tag": "v2-tag"
}
]
}
Loading