mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
Eleven workflows had no top-level permissions block, so any job without its own ran with the repository's default token permissions. Set the least each one needs: read-only contents for the build, test and Crowdin upload workflows, which only check out code and use their own tokens for anything else; issues, pull requests and the Actions cache for the stale bot. Workflows whose jobs already set permissions get a read-only default for any job added later. This clears the actions/missing-workflow-permissions code scanning alerts. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Julian Oes <julian@oes.ch>
81 lines
2.4 KiB
YAML
81 lines
2.4 KiB
YAML
# This workflow will triage pull requests and apply labels based on the
|
|
# PR title and paths that are modified in the pull request.
|
|
# The path labels are set up in .github/labeler.yml, the scope label in
|
|
# Tools/ci/label_pr_scope.py
|
|
#
|
|
# See: https://github.com/actions/labeler
|
|
|
|
name: Labeler
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, edited, synchronize, reopened, ready_for_review]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# Runs that overlap would race to add and remove the scope label.
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
label:
|
|
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
issues: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Label PR title type
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
GH_REPO: ${{ github.repository }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
if [[ ! "$PR_TITLE" =~ ^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)\([a-zA-Z0-9_./-]+\)!?:\ .{5,}$ ]]; then
|
|
echo "No conventional commit type detected; Commit Quality validates title format."
|
|
exit 0
|
|
fi
|
|
|
|
type="${BASH_REMATCH[1]}"
|
|
|
|
case "$type" in
|
|
feat) label="kind:feature" ;;
|
|
fix) label="kind:bug" ;;
|
|
refactor) label="kind:refactor" ;;
|
|
perf) label="kind:improvement" ;;
|
|
test) label="kind:test" ;;
|
|
docs|style|build|ci|chore|revert) label="kind:chore" ;;
|
|
esac
|
|
|
|
current_labels="$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name')"
|
|
|
|
if grep -Fxq "$label" <<< "$current_labels"; then
|
|
echo "PR already has $label."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Adding $label based on PR title type '$type'."
|
|
gh pr edit "$PR_NUMBER" --add-label "$label"
|
|
|
|
- uses: actions/labeler@v6
|
|
with:
|
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
|
|
# pull_request_target checks out the base branch: the script never runs PR code.
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
sparse-checkout: Tools/ci
|
|
fetch-depth: 1
|
|
|
|
- name: Label PR scope
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
run: python3 Tools/ci/label_pr_scope.py --pr "$PR_NUMBER"
|