Skip to content

Commit a6341d9

Browse files
Added workflow to auto-tag docs PRs based on distro sync PRs.
Signed-off-by: Leander Stephen D'Souza <[email protected]>
1 parent c95673e commit a6341d9

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/autotag_docs.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Label docs PRs for ROS Sync
2+
on:
3+
pull_request:
4+
types: [opened]
5+
6+
jobs:
7+
label-docs:
8+
if: |
9+
any(contains(github.event.pull_request.title, $distro),
10+
$distro in ['Kilted Sync', 'Jazzy Sync'])
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Process docs PRs
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
run: |
17+
# Determine ROS distro and label from PR title
18+
pr_title="${{ github.event.pull_request.title }}"
19+
20+
if [[ "$pr_title" == *"Kilted Sync"* ]]; then
21+
ros_distro="kilted"
22+
label="backport-kilted"
23+
24+
elif [[ "$pr_title" == *"Jazzy Sync"* ]]; then
25+
ros_distro="jazzy"
26+
label="backport-jazzy"
27+
fi
28+
29+
# Get PR numbers from commits
30+
prs=$(gh api repos/ros-navigation/navigation2/pulls/${{ github.event.number }}/commits \
31+
--jq '.[].commit.message' | grep -o '#[0-9]\+' | tr -d '#' | sort -u)
32+
33+
# Find and label docs PRs
34+
for pr in $prs; do
35+
36+
# Get cross-referenced events
37+
docs_pr=$(gh api repos/ros-navigation/navigation2/issues/$pr/timeline \
38+
--jq '.[] | select(.event == "cross-referenced" and .source.issue.repository.name == "docs.nav2.org") | .source.issue.number' \
39+
2>/dev/null | head -1)
40+
41+
if [ -n "$docs_pr" ]; then
42+
echo "Labeling docs PR #$docs_pr with '$label'"
43+
gh pr edit $docs_pr --repo ros-navigation/docs.nav2.org --add-label "$label"
44+
else
45+
echo "No cross-referenced docs PR found for navigation2 PR #$pr"
46+
fi
47+
done

0 commit comments

Comments
 (0)