Skip to content

Commit f3032c5

Browse files
committed
add to a PR for each update to main repo branch
1 parent be38078 commit f3032c5

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

.github/workflows/process_docs_changes.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ jobs:
7676
echo 'checking reported links...'
7777
echo "htmlproofer spit out a report of length: $(cat htmlproofer.out | wc -l)"
7878
bb script/analyze_links.clj --htmlproofer-output htmlproofer.out
79-
exit 1
8079
8180
- name: Create the pull request
8281
env:
@@ -87,10 +86,29 @@ jobs:
8786
else
8887
git config user.email "metabase-bot@metabase.com"
8988
git config user.name "Metabase Docs bot"
90-
update_branch="docs-update-${{ github.run_number }}"
91-
git switch --create "${update_branch}"
89+
update_branch="docs-update"
90+
91+
# Check out or create the update branch
92+
if git ls-remote --exit-code --heads origin "$update_branch" > /dev/null; then
93+
git fetch origin "$update_branch"
94+
git switch "$update_branch"
95+
else
96+
git switch --create "$update_branch"
97+
fi
98+
9299
git add _site
93100
git commit --author="Metabase Docs bot <metabase-bot@metabase.com>" --message="Update master and latest docs"
94-
git push --force -u origin "${update_branch}"
95-
gh pr create --title "Refresh docs (${{ github.event.inputs.branch_name }})" --body ""
101+
git push --force origin "$update_branch"
102+
103+
# Check if a PR already exists for this branch
104+
existing_pr=$(gh pr list --head "$update_branch" --json number --jq '.[0].number')
105+
106+
if [ -z "$existing_pr" ]; then
107+
gh pr create \
108+
--title "Refresh docs (${{ github.event.inputs.branch_name }})" \
109+
--body "" \
110+
--head "$update_branch"
111+
else
112+
echo "PR already exists: #$existing_pr"
113+
fi
96114
fi

0 commit comments

Comments
 (0)