From 0bd3ed4fd24916f14451b96cf13b9c2fcfdfd4eb Mon Sep 17 00:00:00 2001 From: didil <1284255+didil@users.noreply.github.com> Date: Fri, 24 Feb 2023 09:48:11 +0000 Subject: [PATCH 1/2] add build caching --- .github/workflows/ci.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cd1c26d..d38696c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,9 +20,8 @@ jobs: run: GOFLAGS=-v make test - publish_container_image: + build_container_image: needs: build_app - if: github.ref == 'refs/heads/main' runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 @@ -46,9 +45,12 @@ jobs: id: set_output_vars run: echo "short_sha=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_OUTPUT - - name: Build and push + - name: Build / Push uses: docker/build-push-action@v4 with: - push: true + context: . + cache-from: type=gha + cache-to: type=gha,mode=max + push: ${{ github.ref == 'ref/heads/main' }} platforms: linux/amd64,linux/arm64 tags: ${{ vars.DOCKER_IMAGE_NAME }}:${{ steps.set_output_vars.outputs.short_sha }} From 11b5462c2d99d46288844aa8ba5751f7af7a85b8 Mon Sep 17 00:00:00 2001 From: didil <1284255+didil@users.noreply.github.com> Date: Fri, 24 Feb 2023 10:04:09 +0000 Subject: [PATCH 2/2] add github actions go cache --- .github/workflows/ci.yaml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d38696c..0bd69d4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,13 +6,30 @@ jobs: build_app: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - name: Set up Go uses: actions/setup-go@v3 with: go-version: 1.19 + - id: go-cache-paths + run: | + echo "::set-output name=go-build::$(go env GOCACHE)" + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + + - uses: actions/checkout@v3 + + - name: Go Build Cache + uses: actions/cache@v3 + with: + path: ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + + - name: Go Mod Cache + uses: actions/cache@v3 + with: + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + - name: Build run: GOFLAGS=-v make build