Skip to content

Commit 6775b43

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 6775b43

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/autotag_docs.yml

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

0 commit comments

Comments
 (0)