-
Notifications
You must be signed in to change notification settings - Fork 212
170 lines (144 loc) · 5.88 KB
/
sync_extra_features_e2e.yml
File metadata and controls
170 lines (144 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Sync Extra Features E2E Branch with Develop
on:
# Trigger when develop branch is updated
push:
branches:
- develop
# Run daily at 11 PM PST (7 AM UTC) to catch any missed syncs
schedule:
- cron: '0 7 * * *'
workflow_dispatch:
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
continue-on-error: true
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 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
- 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
Some features in PWA kit are defaulted to be off in \`develop\` branch (e.g. if they only work with private client).
Hence there is another site that has these features enabled that E2E tests of these extra features are run against.
The \`extra-features-e2e-branch\` is used for this site.
A job is run nightly to sync \`develop\` to \`extra-features-e2e-branch\` branch, but today this automatic sync from \`develop\` to \`extra-features-e2e-branch\` failed due to merge conflicts.
### Conflicting Files:
\`\`\`
${conflictFiles}
\`\`\`
### 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
\`\`\`
### After resolving the conflicts, close this issue
`;
// 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: '🚨 Extra Features E2E Branch Sync Conflict - Manual Resolution Required',
body: issueBody,
labels: ['sync-conflict', 'automation']
});
}
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: 24
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