Skip to content

Harden Actions workflow token scope by setting explicit minimal permissions #169

Harden Actions workflow token scope by setting explicit minimal permissions

Harden Actions workflow token scope by setting explicit minimal permissions #169

Workflow file for this run

name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
build:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
go_version: ['1.25', '1.26']
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v7
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go_version }}
check-latest: true
cache: true
- name: Get dependencies
run: |
go mod download
- name: Build
run: go build -v ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.12.2
args: --timeout=30m
- name: Test
shell: bash
run: |
if [[ "${GITHUB_TOKEN}" != "" ]]; then
go test -v -race -coverprofile=coverage.txt . ./update
else
go test -v -race -short -coverprofile=coverage.txt . ./update
fi
- name: Code coverage with codecov
uses: codecov/codecov-action@v7
with:
env_vars: OS,GO
files: ./coverage.txt
flags: unittests
fail_ci_if_error: false
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}