mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-29 17:38:07 +00:00
173 lines
6.8 KiB
YAML
173 lines
6.8 KiB
YAML
name: Merge Submodule PRs
|
|
|
|
on:
|
|
pull_request:
|
|
types: [closed, labeled]
|
|
|
|
jobs:
|
|
merge-submodules:
|
|
if: |
|
|
github.event.pull_request.merged == true &&
|
|
(github.event.pull_request.base.ref == 'main' || github.event.pull_request.base.ref == 'lts-3.16')
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Extract Branch Name and Base Branch
|
|
run: |
|
|
echo "BRANCH_NAME=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
|
|
echo "BASE_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
|
|
|
|
- name: Merge PR in ee-server (if exists)
|
|
run: |
|
|
PR=$(gh pr list -R ToolJet/ee-server --head "$BRANCH_NAME" --base "$BASE_BRANCH" --state open --json number -q '.[0].number')
|
|
if [ -n "$PR" ]; then
|
|
echo "Found ee-server PR: #$PR targeting $BASE_BRANCH"
|
|
gh pr merge -R ToolJet/ee-server "$PR" --merge --admin
|
|
else
|
|
echo "No open ee-server PR for branch $BRANCH_NAME targeting $BASE_BRANCH"
|
|
fi
|
|
env:
|
|
GH_TOKEN: ${{ secrets.TOKEN_PR }}
|
|
|
|
- name: Merge PR in ee-frontend (if exists)
|
|
run: |
|
|
PR=$(gh pr list -R ToolJet/ee-frontend --head "$BRANCH_NAME" --base "$BASE_BRANCH" --state open --json number -q '.[0].number')
|
|
if [ -n "$PR" ]; then
|
|
echo "Found ee-frontend PR: #$PR targeting $BASE_BRANCH"
|
|
gh pr merge -R ToolJet/ee-frontend "$PR" --merge --admin
|
|
else
|
|
echo "No open ee-frontend PR for branch $BRANCH_NAME targeting $BASE_BRANCH"
|
|
fi
|
|
env:
|
|
GH_TOKEN: ${{ secrets.TOKEN_PR }}
|
|
|
|
|
|
update-submodule-sha:
|
|
needs: merge-submodules
|
|
if: |
|
|
github.event.pull_request.merged == true &&
|
|
(github.event.pull_request.base.ref == 'main' || github.event.pull_request.base.ref == 'lts-3.16')
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout base repo
|
|
uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.TOKEN_PR }}
|
|
ref: ${{ github.event.pull_request.base.ref }}
|
|
submodules: recursive
|
|
|
|
- name: Wait for merge completion
|
|
run: |
|
|
echo "Waiting for submodule merges to complete..."
|
|
sleep 60
|
|
|
|
- name: Update submodules to latest ${{ github.event.pull_request.base.ref }}
|
|
run: |
|
|
git config user.name "adishM98 Bot"
|
|
git config user.email "adish.madhu@gmail.com"
|
|
|
|
# Update submodules to match the base branch
|
|
BASE_BRANCH="${{ github.event.pull_request.base.ref }}"
|
|
|
|
echo "Updating submodules to latest commit SHA from $BASE_BRANCH branch"
|
|
|
|
# Get latest commit SHA from ee-frontend repository
|
|
echo "Fetching latest commit from ToolJet/ee-frontend:$BASE_BRANCH"
|
|
FRONTEND_SHA=$(gh api repos/ToolJet/ee-frontend/branches/$BASE_BRANCH --jq '.commit.sha' 2>/dev/null || gh api repos/ToolJet/ee-frontend/branches/main --jq '.commit.sha')
|
|
echo "Frontend SHA: $FRONTEND_SHA"
|
|
|
|
# Get latest commit SHA from ee-server repository
|
|
echo "Fetching latest commit from ToolJet/ee-server:$BASE_BRANCH"
|
|
SERVER_SHA=$(gh api repos/ToolJet/ee-server/branches/$BASE_BRANCH --jq '.commit.sha' 2>/dev/null || gh api repos/ToolJet/ee-server/branches/main --jq '.commit.sha')
|
|
echo "Server SHA: $SERVER_SHA"
|
|
|
|
# Update submodule pointers to specific commit SHAs
|
|
cd frontend/ee
|
|
git fetch origin $BASE_BRANCH
|
|
if git cat-file -e "$FRONTEND_SHA" 2>/dev/null; then
|
|
git checkout "$FRONTEND_SHA"
|
|
echo "Successfully checked out frontend SHA: $FRONTEND_SHA"
|
|
else
|
|
echo "Error: Frontend SHA $FRONTEND_SHA not found. Fetching all refs..."
|
|
git fetch origin
|
|
git checkout "$FRONTEND_SHA"
|
|
fi
|
|
cd ../..
|
|
|
|
cd server/ee
|
|
git fetch origin $BASE_BRANCH
|
|
if git cat-file -e "$SERVER_SHA" 2>/dev/null; then
|
|
git checkout "$SERVER_SHA"
|
|
echo "Successfully checked out server SHA: $SERVER_SHA"
|
|
else
|
|
echo "Error: Server SHA $SERVER_SHA not found. Fetching all refs..."
|
|
git fetch origin
|
|
git checkout "$SERVER_SHA"
|
|
fi
|
|
cd ../..
|
|
|
|
git add frontend/ee server/ee
|
|
|
|
if git diff --cached --quiet; then
|
|
echo "No submodule updates found." && exit 0
|
|
fi
|
|
env:
|
|
GH_TOKEN: ${{ secrets.TOKEN_PR }}
|
|
|
|
- name: Create PR for submodule update
|
|
id: cpr
|
|
uses: peter-evans/create-pull-request@v6
|
|
with:
|
|
token: ${{ secrets.TOKEN_PR }}
|
|
commit-message: "🚀 chore: update submodules to latest ${{ github.event.pull_request.base.ref }} after auto-merge"
|
|
title: "🚀 chore: update submodules"
|
|
body: "Auto-generated PR to update submodules after base PR merge"
|
|
branch: auto/update-submodules-${{ github.run_id }}
|
|
base: ${{ github.event.pull_request.base.ref }}
|
|
|
|
- name: Auto-merge PR
|
|
if: steps.cpr.outputs.pull-request-number != ''
|
|
run: |
|
|
echo "Merging submodule update PR #${PR_NUMBER}"
|
|
gh pr merge --squash --admin "$PR_NUMBER" --repo ToolJet/ToolJet
|
|
env:
|
|
GH_TOKEN: ${{ secrets.TOKEN_PR }}
|
|
PR_NUMBER: ${{ steps.cpr.outputs.pull-request-number }}
|
|
|
|
check-submodule-prs:
|
|
if: github.event.action == 'labeled' && github.event.label.name == 'ready-to-merge'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Extract Branch Name
|
|
run: echo "BRANCH_NAME=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
|
|
|
|
- name: Check and Comment Linked Submodule PRs
|
|
run: |
|
|
echo "🔍 Checking linked submodule PRs for \`$BRANCH_NAME\`:" > comment.md
|
|
echo "" >> comment.md
|
|
|
|
SERVER_URL=$(gh pr list -R ToolJet/ee-server --head "$BRANCH_NAME" --state open --json url -q '.[0].url')
|
|
FRONTEND_URL=$(gh pr list -R ToolJet/ee-frontend --head "$BRANCH_NAME" --state open --json url -q '.[0].url')
|
|
|
|
if [ -n "$SERVER_URL" ]; then
|
|
echo "✅ ee-server PR - $SERVER_URL" >> comment.md
|
|
else
|
|
echo "❌ No open PR in ee-server" >> comment.md
|
|
fi
|
|
|
|
if [ -n "$FRONTEND_URL" ]; then
|
|
echo "✅ ee-frontend PR - $FRONTEND_URL" >> comment.md
|
|
else
|
|
echo "❌ No open PR in ee-frontend" >> comment.md
|
|
fi
|
|
|
|
echo "" >> comment.md
|
|
echo "📝 **Note**: The submodule PRs will be auto-merged once you merge this base PR-$PR_NUMBER into \`${{ github.event.pull_request.base.ref }}\`." >> comment.md
|
|
|
|
gh pr comment "$PR_NUMBER" --repo ToolJet/ToolJet --body-file comment.md
|
|
|
|
env:
|
|
GH_TOKEN: ${{ secrets.TOKEN_PR }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|