Skip to content

Commit

Permalink
Add CSV output
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Dec 20, 2024
1 parent cd1a928 commit 73cbabe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,28 @@ jobs:
include:
- name: Dockerfile
expected: '["linux/amd64","linux/arm64"]'
expected_csv: 'linux/amd64,linux/arm64'
with:
dockerfile: tests/Dockerfile
- name: Supplied Image
expected: '["linux/amd64","linux/arm64"]'
expected_csv: 'linux/amd64,linux/arm64'
with:
image: ghcr.io/wyrihaximusnet/php:8.3-zts-alpine-dev
- name: Both
expected: '["linux/arm64","linux/amd64","linux/arm","linux/arm","linux/386"]'
expected_csv: 'linux/arm64,linux/amd64,linux/arm,linux/arm,linux/386'
with:
dockerfile: tests/Dockerfile
image: ghcr.io/home-assistant/home-assistant:2024.12.2
- name: Multiple images
expected: '["linux/arm64","linux/amd64"]'
expected_csv: 'linux/arm64,linux/amd64'
with:
image: ghcr.io/home-assistant/home-assistant:2024.12.2,ghcr.io/wyrihaximusnet/php:8.3-zts-alpine-dev
- name: Multiple Dockerfiles
expected: '["linux/amd64","linux/arm64"]'
expected_csv: 'linux/amd64,linux/arm64'
with:
dockerfile: tests/Dockerfile*
steps:
Expand All @@ -39,9 +44,15 @@ jobs:
id: platforms
uses: ./
with: ${{ matrix.with }}
- name: Assert Dockerfile Platforms
- name: Assert ${{ matrix.name }} Platforms (JSON)
uses: nick-fields/assert-action@v2
with:
expected: ${{ matrix.expected }}
actual: ${{ steps.platforms.outputs.platform }}
comparison: exact
- name: Assert ${{ matrix.name }} Platforms (CSV)
uses: nick-fields/assert-action@v2
with:
expected: ${{ matrix.expected_csv }}
actual: ${{ steps.platforms.outputs.platform_csv }}
comparison: exact
11 changes: 10 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ inputs:
default: ''
outputs:
platform:
description: The upstream supported platforms
description: The upstream supported platforms as JSON array
value: ${{ steps.platform.outputs.platform }}
platform_csv:
description: The upstream supported platforms as CSV
value: ${{ steps.platform_csv.outputs.platform_csv }}
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -58,3 +61,9 @@ runs:
else
printf "platform=%s" $(getPlatformsForImage ${{ steps.image.outputs.image }}) >> $GITHUB_OUTPUT
fi
- name: Create CSV from JSON
id: platform_csv
shell: bash
run: |
printf "platform_csv=%s" $(echo "${{ steps.platform.outputs.platform }}" | docker run -q -i --rm ghcr.io/wyrihaximusnet/php:8.3-nts-alpine-slim php -r 'echo str_replace(["[", "\"", "]"], "", trim(fgets(STDIN)));') >> $GITHUB_OUTPUT

0 comments on commit 73cbabe

Please sign in to comment.