From c81d6f2aac6b13601a4fa8688842f9f92dd823ee Mon Sep 17 00:00:00 2001 From: dsame Date: Sat, 4 Nov 2023 07:24:24 +0100 Subject: [PATCH] Add go build caching --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 801dd15..a9bf3a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,11 @@ jobs: build-n-deploy: runs-on: ubuntu-latest + env: + GOOS: linux + GOARCH: amd64 + steps: - - uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v4 @@ -16,8 +19,32 @@ go-version: 1.21.x cache: false + + - name: Get Go cached paths + run: | + echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + + - name: Set up dependencies cache + uses: actions/cache@v3 + with: + path: | + ${{ env.cache }} + key: setup-go-deps-${{ runner.os }}-go-${{ hashFiles('go.sum go.mod') }} + + - run: echo "$GOOS $GOARCH" > /tmp/env + + - name: Set up intermediate built files cache + uses: actions/cache@v3 + with: + path: | + ${{ env.modcache }} + key: setup-go-build-${{ env.GOOS }}-${{ env.GOARCH }}-${{ runner.os }}-go-${{ hashFiles('**/*.go /tmp/env') }} + restore-keys: | + setup-go-build-${{ env.GOOS }}-${{ env.GOARCH }} + - name: Build Linux binary - run: GOOS=linux GOARCH=amd64 go build + run: build - name: Build Docker image run: docker build -t ${{ secrets.DOCKER_USERNAME }}/az-appservice .