diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 982bc2e..74ce8ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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 diff --git a/README.md b/README.md index b842eae..9959d82 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,11 @@ it will get the platforms for all of them but only return the platforms that are ## Output -This action only outputs a list of platforms as JSON through `platform`. +This action only outputs a list of platforms as JSON through `platform`, and as CSV `platform_csv`. + +For example when the found platforms are `linux/arm64` and `linux/amd64` the outputs are the following: +* `plarform`: `["linux/arm64","linux/amd64"]` +* `platform_csv`: `linux/arm64,linux/amd64` ## Example diff --git a/action.yaml b/action.yaml index 173cfd3..b04bd32 100644 --- a/action.yaml +++ b/action.yaml @@ -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: @@ -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