mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-13 03:24:39 +00:00
Add an explicit top-level permissions block to the GitHub Actions workflows that were relying on the default token permissions. Each workflow now defaults to contents: read, with additional scopes granted only where a job needs them: * nightly-trivy-scan keeps security-events: write at the job level to upload SARIF results, plus contents: read for checkout. * stale-issues gets issues: write and pull-requests: write for the actions/stale action to label and close stale items. Setting least-privilege permissions reduces the blast radius if a workflow or one of its dependencies is compromised, and satisfies the CLOMonitor token_permissions check. Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
37 lines
1.1 KiB
YAML
37 lines
1.1 KiB
YAML
on:
|
|
workflow_call:
|
|
inputs:
|
|
ref:
|
|
description: "The target branch's ref"
|
|
required: true
|
|
type: string
|
|
outputs:
|
|
version:
|
|
description: "The expected Go version"
|
|
value: ${{ jobs.extract.outputs.version }}
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
extract:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.pick-version.outputs.version }}
|
|
steps:
|
|
- name: Check out the code
|
|
uses: actions/checkout@v7
|
|
|
|
- id: pick-version
|
|
run: |
|
|
if [ "${{ inputs.ref }}" == "main" ]; then
|
|
version=$(grep '^go ' go.mod | awk '{print $2}' | cut -d. -f1-2)
|
|
else
|
|
goDirectiveVersion=$(grep '^go ' go.mod | awk '{print $2}')
|
|
toolChainVersion=$(grep '^toolchain ' go.mod | awk '{print $2}' | sed 's/^go//')
|
|
version=$(printf "%s\n%s\n" "$goDirectiveVersion" "$toolChainVersion" | sort -V | tail -n1)
|
|
fi
|
|
|
|
echo "version=$version"
|
|
echo "version=$version" >> $GITHUB_OUTPUT
|