name: Set and restore cache
author: Jeff Kim
description: 'Prepare golang application'
inputs:
  key:
    description: 'Unique key for cache'
    required: false
    default: ${{ github.sha }}

runs:
  using: "composite"
  steps:
  - uses: actions/cache@v4
    with:
      path: |
        ~/.cache/go-build
        ~/go/pkg/mod
      key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
      restore-keys: |
        ${{ runner.os }}-go-${{ key }}
