Skip to content

Commit

Permalink
Merge pull request #21 from WyriHaximusNet/use-actoin-to-get-platforms
Browse files Browse the repository at this point in the history
Use action to get image platforms
  • Loading branch information
WyriHaximus authored Feb 6, 2025
2 parents 475e38e + ff7e166 commit eb2dcfa
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@ on:
schedule:
- cron: '0 0 * * 0'
jobs:
supported-arch-matrix:
name: Supported processor architectures
supported-platform-matrix:
name: Supported processor platforms
runs-on: ubuntu-latest
needs:
- lint-dockerfile
outputs:
arch: ${{ steps.supported-arch-matrix.outputs.arch }}
platform: ${{ steps.supported-platform-matrix.outputs.platform }}
steps:
- uses: actions/checkout@v4
- id: supported-arch-matrix
name: Generate Arch
run: |
echo "arch=[\"linux/amd64\",\"linux/arm64\"]" >> $GITHUB_OUTPUT
- id: supported-platform-matrix
name: Generate platform
uses: WyriHaximus/github-action-oci-image-supported-platforms@main
lint-dockerfile:
name: Lint Dockerfile
runs-on: ubuntu-latest
Expand All @@ -34,9 +30,9 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: ${{ fromJson(needs.supported-arch-matrix.outputs.arch) }}
platform: ${{ fromJson(needs.supported-platform-matrix.outputs.platform) }}
needs:
- supported-arch-matrix
- supported-platform-matrix
- lint-dockerfile
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -66,9 +62,9 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: ${{ fromJson(needs.supported-arch-matrix.outputs.arch) }}
platform: ${{ fromJson(needs.supported-platform-matrix.outputs.platform) }}
needs:
- supported-arch-matrix
- supported-platform-matrix
- build-docker-image
runs-on: ubuntu-latest
steps:
Expand All @@ -87,12 +83,12 @@ jobs:
tests:
name: Test ${{ matrix.platform }}
needs:
- supported-arch-matrix
- supported-platform-matrix
- scan-vulnerability
strategy:
fail-fast: false
matrix:
platform: ${{ fromJson(needs.supported-arch-matrix.outputs.arch) }}
platform: ${{ fromJson(needs.supported-platform-matrix.outputs.platform) }}
runs-on: ubuntu-latest
steps:
- name: Prepare
Expand All @@ -113,7 +109,7 @@ jobs:
if: (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/main'
name: Push
needs:
- supported-arch-matrix
- supported-platform-matrix
- tests
runs-on: ubuntu-latest
services:
Expand Down Expand Up @@ -146,7 +142,7 @@ jobs:
- run: rm -Rf /tmp/docker-image/
- run: docker images
- run: |
archs=${{ join(fromJson(needs.supported-arch-matrix.outputs.arch), ',') }}
archs=${{ join(fromJson(needs.supported-platform-matrix.outputs.platform), ',') }}
for arch in ${archs//,/ }
do
docker tag "${{ env.DOCKER_IMAGE }}:${arch//\//-}" "localhost:5000/${{ env.DOCKER_IMAGE }}:${arch//\//-}"
Expand All @@ -172,4 +168,4 @@ jobs:
context: .
file: docker-file-${{ matrix.registry }}-wyrihaximusnet-github-action-runner
tags: ghcr.io/${{ env.DOCKER_IMAGE }}:latest,ghcr.io/${{ env.DOCKER_IMAGE }}:${{ steps.time.outputs.time }}
platforms: ${{ join(fromJson(needs.supported-arch-matrix.outputs.arch), ',') }}
platforms: ${{ join(fromJson(needs.supported-platform-matrix.outputs.platform), ',') }}

0 comments on commit eb2dcfa

Please sign in to comment.