Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
kaznak committed Dec 14, 2023
1 parent 0f233f6 commit 2ab4ce3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 37 deletions.
17 changes: 12 additions & 5 deletions .github/generate-strategy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@

set -eu

repository_with_trailing_slash=$1

jq '
. as $root |
($root.dir // $root.imgname + "/" + $root.variant) as $dir |
{
dir: ($root.dir // $root.imgname + "/" + $root.variant),
imgtags: ($root.imgtags // [$root.variant])
} as $tmp |
{
platforms: ($root.platforms // ["linux/amd64"]),
tags: ($root.tags // [$root.variant]),
dir: $dir,
imgtags: $tmp.imgtags,
tags: ($tmp.imgtags | map("'$repository_with_trailing_slash'\($root.imgname):\(.)")),
dir: $tmp.dir,
files: {
dockerfile: ($dir + "/Dockerfile"),
dockleignore: ($dir + "/.dockleignore")
dockerfile: ($tmp.dir + "/Dockerfile"),
dockleignore: ($tmp.dir + "/.dockleignore")
}
} as $defaults |
.platforms // $defaults.platforms | .[] | . as $platform |
Expand All @@ -27,6 +33,7 @@ jq '
variant: $root.variant,
platform: $platform,
imgname: $root.imgname,
imgtags: $defaults.imgtags,
tags: ($root.tags // $defaults.tags),
dir: ($root.dir // $defaults.dir),
files: {
Expand Down
21 changes: 0 additions & 21 deletions .github/matrix-to-tag.sh

This file was deleted.

13 changes: 3 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
shell: bash
run: |
cat */*/strategy.json \
| bash .github/generate-strategy.sh \
| bash .github/generate-strategy.sh ${IMAGE_REPOSITORY_DIR}/ \
| { echo -n "strategy=" ; jq -c . ; } \
| tee -a $GITHUB_OUTPUT
Expand All @@ -50,13 +50,6 @@ jobs:
with:
platforms: ${{ matrix.platforms }}

- name: Generate and set Tags
env:
MATRIX: ${{ toJson(matrix) }}
run: |
bash .github/matrix-to-tag.sh ${IMAGE_REPOSITORY_DIR}/ <<<${MATRIX} \
| tee -a $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -74,7 +67,7 @@ jobs:
file: ${{ matrix.file }}
push: false
load: true
tags: ${{ env.TAGS }}
tags: ${{ join(matrix.tags,',') }}

- name: Setup dockle
env:
Expand All @@ -85,7 +78,7 @@ jobs:
- name: Dockle scan
uses: erzz/dockle-action@v1
with:
image: "${{ env.IMAGE_REPOSITORY_DIR }}/${{ matrix.imgname }}:${{ matrix.tags[0] }}"
image: "${{ matrix.tags[0] }}"
exit-code: '1'
failure-threshold: WARN
accept-keywords: key
Expand Down
2 changes: 1 addition & 1 deletion cloudnativepg-configured/16/strategy.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CloudNativePG Configured",
"imgname": "cloudnativepg-configured",
"variant": "16",
"imgname": "cloudnativepg-configured",
"platforms": ["linux/amd64"]
}

0 comments on commit 2ab4ce3

Please sign in to comment.