fix: github secrets #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | ||
name: Go CI | ||
on: | ||
workflow_call: | ||
secrets: | ||
github_username: | ||
required: false | ||
github_token: | ||
required: false | ||
inputs: | ||
go-version: | ||
description: "The version of Go to use" | ||
required: false | ||
type: string | ||
go-build-args: | ||
description: "The arguments to pass to the go build command" | ||
required: false | ||
default: "." | ||
type: string | ||
go-test-args: | ||
description: "The arguments to pass to the go test command" | ||
required: false | ||
default: "-cover -v ./..." | ||
type: string | ||
go-bench-args: | ||
description: "The arguments to pass to the go test command when running benchmarks" | ||
required: false | ||
default: "-bench=./..." | ||
type: string | ||
go-private: | ||
description: "The GOPRIVATE environment variable" | ||
required: false | ||
type: string | ||
run-benchmarks: | ||
description: "Run benchmarks" | ||
required: false | ||
default: true | ||
type: boolean | ||
jobs: | ||
build: | ||
env: | ||
GOPRIVATE: "${{ inputs.go-private }}" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Go | ||
if: inputs.go-version != '' | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ inputs.go-version }} | ||
- name: Set up Go | ||
if: inputs.go-version == '' | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: go.mod | ||
- name: Setup private repository access | ||
if: inputs.go-private != '' | ||
run: git config --global url."https://${{ secrets.github_username }}:${{ secrets.github_token }}@github.com".insteadOf "https://github.com" | ||
- name: Install dependencies | ||
run: | | ||
go env | ||
go mod download | ||
go mod verify | ||
- name: Build | ||
run: go build ${{ inputs.go-build-args }} | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: latest | ||
args: --timeout=5m --verbose | ||
- name: Run tests | ||
run: go test ${{ inputs.go-test-args }} | ||
- name: Run benchmarks | ||
if: inputs.run-benchmarks | ||
run: go test ${{ inputs.go-bench-args }} |