Skip to content

Need to update changelog for some reason #3

Need to update changelog for some reason

Need to update changelog for some reason #3

name: Sync More Logins E2E Branch with Develop
on:
# Trigger when develop branch is updated
push:
branches:
- develop
- W-18685522-reset-and-passwordless-integration-test
# Run daily at 11 PM PST (7 AM UTC) to catch any missed syncs
schedule:
- cron: '0 7 * * *'
# Allow manual triggering with options
workflow_dispatch:
inputs:
force_sync:
description: 'Force sync even if conflicts exist (overwrites E2E branch)'
required: false
default: false
type: boolean
permissions:
contents: write
issues: write
pull-requests: read
jobs:
sync-branch:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
git config --global user.name ${{ secrets.GIT_CONFIG_USERNAME }}
git config --global user.email ${{ secrets.GIT_CONFIG_EMAIL }}
- name: Sync extra-features-e2e-branch with develop
id: sync
run: |
set -e
# Fetch all branches
git fetch origin
# Check if the target branch exists
if ! git show-ref --verify --quiet refs/remotes/origin/extra-features-e2e-branch; then
echo "Branch extra-features-e2e-branch does not exist. Creating it from develop..."
git checkout -b extra-features-e2e-branch origin/develop
git push origin extra-features-e2e-branch
echo "✅ Created extra-features-e2e-branch branch from develop"
echo "status=created" >> $GITHUB_OUTPUT
exit 0
fi
# Switch to the target branch
git checkout extra-features-e2e-branch
git reset --hard origin/extra-features-e2e-branch
# Check if we're already up to date
if git merge-base --is-ancestor origin/develop HEAD; then
echo "✅ extra-features-e2e-branch is already up to date with develop"
echo "status=up-to-date" >> $GITHUB_OUTPUT
exit 0
fi
if [ "${{ github.event.inputs.force_sync }}" = "true" ]; then
echo "🔧 Force sync requested. Resetting to develop..."
git reset --hard origin/develop
git push --force origin extra-features-e2e-branch
echo "⚠️ Force synced extra-features-e2e-branch with develop (all conflicts overwritten)"
echo "status=force-synced" >> $GITHUB_OUTPUT
else
# Default merge strategy
if git merge origin/develop --no-edit; then
echo "✅ Successfully merged develop into extra-features-e2e-branch"
git push origin extra-features-e2e-branch
echo "status=merged" >> $GITHUB_OUTPUT
else
echo "❌ Merge conflicts detected!"
echo "📋 Files with conflicts:"
git diff --name-only --diff-filter=U || true
git merge --abort
echo "status=conflict" >> $GITHUB_OUTPUT
exit 1
fi
fi
- name: Create conflict resolution issue
if: steps.sync.outputs.status == 'conflict'
uses: actions/github-script@v7
with:
script: |
const conflictFiles = `${{ steps.sync.outputs.conflict_files || 'Unknown files' }}`;
const issueBody = `
## 🚨 Automatic Sync Failed - Merge Conflicts Detected
The automatic sync from \`develop\` to \`extra-features-e2e-branch\` failed due to merge conflicts.
### Conflicting Files:
\`\`\`
${conflictFiles}
\`\`\`
### Resolution Options:
#### Option 1: Manual Resolution
\`\`\`bash
git checkout extra-features-e2e-branch
git pull origin extra-features-e2e-branch
git merge develop
# Resolve conflicts manually
git add .
git commit -m "Resolve merge conflicts from develop"
git push origin extra-features-e2e-branch
\`\`\`
#### Option 2: Force Sync (Overwrites E2E changes)
Go to [Actions](../../actions/workflows/sync-more-logins-e2e.yml) and run the workflow manually with "Force sync" enabled.
#### Option 3: Reset Strategy
Go to [Actions](../../actions/workflows/sync-more-logins-e2e.yml) and run the workflow manually with "reset" strategy.
### Auto-close
This issue will be automatically closed when the sync succeeds.
`;
// Check if issue already exists
const existingIssues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'sync-conflict'
});
if (existingIssues.data.length === 0) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🚨 E2E Branch Sync Conflict - Manual Resolution Required',
body: issueBody,
labels: ['sync-conflict', 'automation']
});
}
- name: Close conflict resolution issues
if: steps.sync.outputs.status != 'conflict'
uses: actions/github-script@v7
with:
script: |
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'sync-conflict'
});
for (const issue of issues.data) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed'
});
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: '✅ Sync conflict resolved automatically. Closing this issue.'
});
}
deploy:
needs: sync-branch
if: needs.sync-branch.outputs.status != 'conflict' && needs.sync-branch.outputs.status != 'up-to-date'
runs-on: ubuntu-latest
environment: extra-features-e2e
steps:
- name: Checkout extra-features-e2e-branch branch
uses: actions/checkout@v4
with:
ref: extra-features-e2e-branch
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
- name: Install Monorepo Dependencies
run: |
# Install node dependencies
node ./scripts/gtime.js monorepo_install npm ci
- name: Build project
run: |
cd packages/template-retail-react-app
npm run build
- name: Create MRT credentials file
uses: "./.github/actions/create_mrt"
with:
mobify_user: ${{ secrets.MOBIFY_CLIENT_USER }}
mobify_api_key: ${{ secrets.MOBIFY_CLIENT_API_KEY }}
- name: Deploy to MRT
uses: "./.github/actions/push_to_mrt"
with:
CWD: "./packages/template-retail-react-app"
TARGET: extra-features-e2e
PROJECT: scaffold-pwa
MESSAGE: "Auto-sync from develop - build ${{ github.run_id }} (${{ github.sha }})"
FLAGS: --wait