Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions .github/workflows/integrate-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: Integrate Develop to Staging

on:
push:
branches:
- develop

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
create-or-update-pr:
name: Create or Update PR to Staging
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.10.0'

- name: Check for existing PR
id: check-pr
run: |
EXISTING_PR=$(gh pr list --base staging --head develop --json number --jq '.[0].number' || echo "")

if [ -n "$EXISTING_PR" ]; then
echo "pr_exists=true" >> $GITHUB_OUTPUT
echo "pr_number=$EXISTING_PR" >> $GITHUB_OUTPUT
echo "Found existing PR #$EXISTING_PR"
else
echo "pr_exists=false" >> $GITHUB_OUTPUT
echo "No existing PR found"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get commit information
id: commit-info
run: |
# Fetch staging branch
git fetch origin staging:staging || echo "Staging branch not found"

# Get the latest commits from develop that aren't in staging
if git rev-parse --verify origin/staging >/dev/null 2>&1; then
COMMITS=$(git log --pretty=format:"- %s (%h)" origin/staging..HEAD | head -20)
COMMIT_COUNT=$(git rev-list --count origin/staging..HEAD)
else
COMMITS=$(git log --pretty=format:"- %s (%h)" HEAD | head -20)
COMMIT_COUNT=$(git rev-list --count HEAD)
fi

# Escape for GitHub Actions output
COMMITS="${COMMITS//'%'/'%25'}"
COMMITS="${COMMITS//$'\n'/'%0A'}"
COMMITS="${COMMITS//$'\r'/'%0D'}"

echo "commits<<EOF" >> $GITHUB_OUTPUT
echo "$COMMITS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "commit_count=$COMMIT_COUNT" >> $GITHUB_OUTPUT

# Get timestamp
TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT

- name: Create PR to staging
if: steps.check-pr.outputs.pr_exists == 'false'
run: |
COMMIT_COUNT="${{ steps.commit-info.outputs.commit_count }}"
TIMESTAMP="${{ steps.commit-info.outputs.timestamp }}"

# Create PR body file
{
echo "## 🚀 Integration from develop to staging"
echo ""
echo "### 📊 Summary"
echo "- **Commits**: ${COMMIT_COUNT} new commits"
echo "- **Created**: ${TIMESTAMP}"
echo "- **Auto-generated**: This PR was automatically created by the integration workflow"
echo ""
echo "### 📝 Recent Commits"
echo "${{ steps.commit-info.outputs.commits }}"
echo ""
echo "### 🔍 What happens next?"
echo "1. Review the changes in this PR"
echo "2. Run any necessary QA tests"
echo "3. When approved and merged, the staging workflow will:"
echo " - Check for changesets"
echo " - If found, create beta releases"
echo " - Automatically create a PR to main"
echo ""
echo "### ⚡ Notes"
echo "- This PR will be automatically updated with new commits to develop"
echo "- Multiple features can accumulate in this single PR"
echo "- Approval triggers the beta release process"
} > pr-body.md

gh pr create \
--base staging \
--head develop \
--title "🔄 Integrate develop → staging" \
--body-file pr-body.md \
--label "auto-updated"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update existing PR
if: steps.check-pr.outputs.pr_exists == 'true'
run: |
PR_NUMBER="${{ steps.check-pr.outputs.pr_number }}"
COMMIT_COUNT="${{ steps.commit-info.outputs.commit_count }}"
TIMESTAMP="${{ steps.commit-info.outputs.timestamp }}"
COMMITS="${{ steps.commit-info.outputs.commits }}"

# Update PR title with commit count
gh pr edit $PR_NUMBER \
--title "🔄 Integrate develop → staging (${COMMIT_COUNT} commits)"

# Get current PR body
CURRENT_BODY=$(gh pr view $PR_NUMBER --json body --jq '.body')

# Create updated section
UPDATED_SECTION="### 🔄 Last Updated: ${TIMESTAMP}\nNew commits: ${COMMIT_COUNT}\n\n### 📝 Recent Commits\n${COMMITS}"

# Update or append the updated section
if echo "$CURRENT_BODY" | grep -q "### 🔄 Last Updated:"; then
# Replace existing update section
NEW_BODY=$(echo "$CURRENT_BODY" | sed '/### 🔄 Last Updated:/,/### 📝 Recent Commits/d' | sed '/^$/d')
NEW_BODY="$NEW_BODY\n\n$UPDATED_SECTION"
else
# Append update section
NEW_BODY="$CURRENT_BODY\n\n---\n\n$UPDATED_SECTION"
fi

# Update PR body
echo "$NEW_BODY" > pr-body-update.md
gh pr edit $PR_NUMBER --body-file pr-body-update.md

# Add labels
gh pr edit $PR_NUMBER \
--add-label "needs-review"

# Set as ready for review
gh pr ready $PR_NUMBER || true

echo "✅ Updated PR #${PR_NUMBER} with ${COMMIT_COUNT} new commits"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
File renamed without changes.
7 changes: 4 additions & 3 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- develop
- staging

jobs:
lint-and-type-check:
Expand Down Expand Up @@ -81,7 +82,7 @@ jobs:
echo "❌ Main package build output not found"
exit 1
fi

# Check sub-packages
for pkg in packages/*/; do
if [ -d "$pkg" ] && [ -f "$pkg/package.json" ]; then
Expand All @@ -91,5 +92,5 @@ jobs:
fi
fi
done
echo "✅ All packages built successfully"

echo "✅ All packages built successfully"
Loading
Loading