From cc592cb382a0a67d829854745511b50e47bfad88 Mon Sep 17 00:00:00 2001 From: cofob Date: Sat, 31 Aug 2024 23:37:24 +0400 Subject: [PATCH] Use shared matrix --- .github/workflows/ci.yml | 106 ++++----------------------------------- 1 file changed, 10 insertions(+), 96 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ee46a72..211bc49b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -182,8 +182,11 @@ jobs: run: nix run . -- validate docker: - name: Build Docker container (x86_64) + name: Build Docker container runs-on: ubuntu-latest + strategy: + matrix: + target: [x86_64, aarch64] needs: build-nix permissions: contents: read @@ -200,6 +203,10 @@ jobs: with: name: cofob authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: aarch64 - name: Login to GitHub Container Registry uses: docker/login-action@v3 @@ -250,7 +257,7 @@ jobs: - name: Build remote run: | - nix build .#fastside-docker + nix --system ${{ matrix.target }}-linux build .#fastside-docker docker load < result - name: Push to registry @@ -263,100 +270,7 @@ jobs: - name: Build baked run: | - nix build .#fastside-docker-baked-services - docker load < result - - - name: Push to registry - run: | - tags="${{ steps.meta2.outputs.tags }}" - for tag in $tags; do - docker tag fastside $tag - docker push $tag - done - - docker-aarch64: - name: Build Docker container (aarch64) - runs-on: ubuntu-latest - needs: build-nix-aarch64 - permissions: - contents: read - packages: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: aarch64 - - name: Setup Nix - uses: cachix/install-nix-action@v25 - with: - nix_path: "${{ env.nix_path }}" - - name: Setup cachix - uses: cachix/cachix-action@v14 - with: - name: cofob - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Lowercase repository name - id: repo - uses: ASzc/change-string-case-action@v6 - with: - string: ${{ github.repository }} - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/${{ steps.repo.outputs.lowercase }}-aarch64 - tags: | - type=schedule - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} - - - name: Docker meta (baked) - id: meta2 - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/${{ steps.repo.outputs.lowercase }}-aarch64/baked - tags: | - type=schedule - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} - - - name: Build remote (aarch64) - run: | - nix --system aarch64-linux build .#fastside-docker - docker load < result - - - name: Push to registry - run: | - tags="${{ steps.meta.outputs.tags }}" - for tag in $tags; do - docker tag fastside $tag - docker push $tag - done - - - name: Build baked (aarch64) - run: | - nix --system aarch64-linux build .#fastside-docker-baked-services + nix --system ${{ matrix.target }}-linux build .#fastside-docker-baked-services docker load < result - name: Push to registry