@@ -57,20 +57,33 @@ jobs:
5757
5858 if [ "$IS_WIDGET" == "true" ]; then
5959 BASE_BRANCH="widget-develop"
60+ # Check if widget-develop exists on remote
61+ if git ls-remote --exit-code --heads https://github.com/${{ github.repository }}.git widget-develop > /dev/null 2>&1; then
62+ CHECKOUT_REF="widget-develop"
63+ CREATE_WIDGET_BRANCH="false"
64+ else
65+ echo "widget-develop branch does not exist, will create from main"
66+ CHECKOUT_REF="main"
67+ CREATE_WIDGET_BRANCH="true"
68+ fi
6069 else
6170 BASE_BRANCH="main"
71+ CHECKOUT_REF="main"
72+ CREATE_WIDGET_BRANCH="false"
6273 fi
6374
6475 echo "base_branch=$BASE_BRANCH" >> $GITHUB_OUTPUT
76+ echo "checkout_ref=$CHECKOUT_REF" >> $GITHUB_OUTPUT
77+ echo "create_widget_branch=$CREATE_WIDGET_BRANCH" >> $GITHUB_OUTPUT
6578 echo "is_widget_change=$IS_WIDGET" >> $GITHUB_OUTPUT
66- echo "Using base branch: $BASE_BRANCH (widget change: $IS_WIDGET)"
79+ echo "Using base branch: $BASE_BRANCH, checkout ref: $CHECKOUT_REF (widget change: $IS_WIDGET)"
6780 env :
6881 GH_TOKEN : ${{ secrets.OCS_DOCS_PAT }}
6982
7083 - name : Checkout repository
7184 uses : actions/checkout@v4
7285 with :
73- ref : ${{ steps.determine_branch.outputs.base_branch }}
86+ ref : ${{ steps.determine_branch.outputs.checkout_ref }}
7487 fetch-depth : 1
7588
7689 - name : Configure git
@@ -147,6 +160,13 @@ jobs:
147160
148161 - name : Create branch for changelog update
149162 run : |
163+ # Create widget-develop from main if needed
164+ if [ "${{ steps.determine_branch.outputs.create_widget_branch }}" == "true" ]; then
165+ echo "Creating widget-develop branch from main..."
166+ git push origin HEAD:widget-develop
167+ echo "Created widget-develop branch"
168+ fi
169+
150170 BRANCH_NAME="changelog-pr-${{ steps.set_vars.outputs.pr_number }}-${{ github.run_number }}"
151171 git checkout -b $BRANCH_NAME
152172 echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
0 commit comments