name: Go

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Set up Go
      uses: actions/setup-go@v2
      with:
        go-version: 1.17
    
    - name: Test
      run: go test -v ./...

    - name: Build CookieMonster
      run: go build -o cookiemonster -ldflags "-X main.commitHash=$GITHUB_SHA" ./cmd/cookiemonster