diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 29006cd..c09f0fa 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -27,11 +27,17 @@ jobs: - uses: actions/checkout@v2 - uses: docker/setup-qemu-action@v1 - uses: docker/setup-buildx-action@v1 + - uses: actions/cache@v2 + with: + path: /tmp/buildx + key: buildx-${{ runner.os }}-${{ github.sha }} + restore-keys: | + buildx-${{ runner.os }}- - uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.repository_owner }} - password: ${{ secrets.CR_PAT }} + password: ${{ secrets.GITHUB_TOKEN }} - run: make docker-build if: github.event_name == 'pull_request' - run: make docker-build-push diff --git a/Makefile b/Makefile index cbd2497..8f14ebf 100644 --- a/Makefile +++ b/Makefile @@ -41,16 +41,19 @@ DOCKER_REPOSITORY := ghcr.io/int128/slack-docker .PHONY: docker-build docker-build: Dockerfile docker buildx build . \ - --cache-from=type=registry,ref=$(DOCKER_REPOSITORY):latest \ + --output=type=image,push=false \ + --cache-from=type=local,src=/tmp/buildx \ + --cache-to=type=local,mode=max,dest=/tmp/buildx.new \ --platform=linux/amd64,linux/arm64 + rm -fr /tmp/buildx + mv /tmp/buildx.new /tmp/buildx .PHONY: docker-build-push docker-build-push: Dockerfile docker buildx build . \ --build-arg=VERSION=$(VERSION) \ --tag=$(DOCKER_REPOSITORY):$(VERSION) \ - --cache-from=type=registry,ref=$(DOCKER_REPOSITORY):latest \ - --cache-to=type=inline \ + --cache-from=type=local,src=/tmp/buildx \ --platform=linux/amd64,linux/arm64 \ --push