This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
58 lines (51 loc) 路 2.27 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Metadata syntax: <https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions>
name: Setup Go environment with a Cache
description: Setup a Go environment and add it to the PATH, additionally enable the module & build caching
inputs:
go-version:
description: The Go version to download (if necessary) and use. Supports semver spec and ranges
required: false
go-version-file:
description: Path to the go.mod or go.work file, determines Golang version to use. Used in place of `go-version` input
required: false
cache-key-suffix:
description: Optional cache key suffix
default: ''
github-token:
description: GitHub auth token. Since there's a default, this is typically not supplied by the user
required: false
default: ${{ github.token }}
runs:
using: composite
steps:
- shell: bash
run: >
echo '::warning title=Action gacts/setup-go-with-cache is deprecated::Since actions/setup-go now supports
caching and restoring go modules and build outputs, this action is no longer necessary. Please use
`actions/setup-go` directly. To migrate, simply replace `uses: gacts/setup-go-with-cache@v1`
with `uses: actions/setup-go@v5` (or later) in your workflow file. Read more details here:
https://github.com/actions/setup-go?tab=readme-ov-file#caching-dependency-files-and-build-outputs'
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
go-version-file: ${{ inputs.go-version-file }}
token: ${{ inputs.github-token }}
- name: Determine Golang cache paths
id: golang-path
shell: bash
run: |
echo "build=$(go env GOCACHE)" >>"$GITHUB_OUTPUT"
echo "module=$(go env GOMODCACHE)" >>"$GITHUB_OUTPUT"
- name: Setup Golang cache
uses: actions/cache@v4
with:
path: |
${{ steps.golang-path.outputs.build }}
${{ steps.golang-path.outputs.module }}
key: ${{ runner.os }}-golang${{ inputs.cache-key-suffix && '-' }}${{ inputs.cache-key-suffix }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang${{ inputs.cache-key-suffix && '-' }}${{ inputs.cache-key-suffix }}-
branding:
icon: box
color: orange