From 1ec47efbbcfdcfc0744940ac0f6d4d58d7d9b188 Mon Sep 17 00:00:00 2001 From: itchyny Date: Sat, 8 Jul 2023 10:14:16 +0900 Subject: [PATCH] Build Docker image using pre-built executables --- .github/workflows/ci.yml | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b490dce130..149c02ca2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ on: push: branches: - master + - improve-docker-image-build tags: - "jq-*" pull_request: @@ -230,21 +231,41 @@ jobs: jq-*.zip docker: + needs: linux + strategy: + matrix: + platform: [linux/amd64, linux/arm64] + include: + - platform: linux/amd64 + suffix: linux-ubuntu-22.04-gcc-x86_64 + - platform: linux/arm64 + suffix: linux-ubuntu-22.04-gcc-aarch64 runs-on: ubuntu-latest permissions: packages: write - if: startsWith(github.ref, 'refs/tags/jq-') + # if: startsWith(github.ref, 'refs/tags/jq-') steps: - name: Clone repository uses: actions/checkout@v3 + - name: Download executable + uses: actions/download-artifact@v3 with: - submodules: true + name: jq-${{ matrix.suffix }} + - name: Create Dockerfile + run: | + cat <Dockerfile + FROM scratch + COPY AUTHORS COPYING jq / + RUN ["chmod", "+x", "/jq"] + RUN ["/jq", "--version"] + ENTRYPOINT ["/jq"] + EOF - name: Docker metadata uses: docker/metadata-action@v4 id: metadata with: images: ghcr.io/${{ github.repository }} - tags: type=match,pattern=jq-(.*),group=1,value=${{ github.ref_name }} + tags: latest # type=match,pattern=jq-(.*),group=1,value=${{ github.ref_name }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx @@ -261,7 +282,7 @@ jobs: context: . push: true provenance: false - platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x + platforms: ${{ matrix.platform }} tags: ${{ steps.metadata.outputs.tags }} labels: ${{ steps.metadata.outputs.labels }} @@ -269,7 +290,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: write - needs: [linux, macos, windows, dist] + needs: [linux, macos, windows, dist, docker] if: startsWith(github.ref, 'refs/tags/jq-') steps: - name: Clone repository