Skip to content

Commit

Permalink
Add go build caching
Browse files Browse the repository at this point in the history
  • Loading branch information
dsame committed Nov 4, 2023
1 parent dbbb03e commit c81d6f2
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,44 @@
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
with:
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 .
Expand Down

0 comments on commit c81d6f2

Please sign in to comment.