Skip to content

Commit 35902cb

Browse files
resolved git merge conflicts
2 parents 9c6f6f1 + 3276fd8 commit 35902cb

File tree

12 files changed

+191
-68
lines changed

12 files changed

+191
-68
lines changed

.github/workflows/repo-sync.yml

Lines changed: 171 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,80 +6,186 @@ on:
66
branches:
77
- dev # Change this to your default branch if needed
88

9+
env:
10+
BRANCH : dev # Change this to your default branch if needed
11+
SITECORE_REPO: contentstack-expert-services/migration-tool-sitecore # Change this to your sitecore repo
12+
CONTENTFUL_REPO: contentstack-expert-services/migration-tool-contentful # Change this to your contentful repo
13+
WORDPRESS_REPO: contentstack-expert-services/migration-tool-wordpress # Change this to your wordpress repo
14+
RSYNC_SITECORE_API_SRC_SERVICES_EXCLUDES: "--exclude 'src/services/contentful/' --exclude 'src/services/contentful.service.ts' --exclude 'src/services/wordpress.service.ts'" # Include only sitecore services
15+
RSYNC_CONTENTFUL_API_SRC_SERVICES_EXCLUDES: "--exclude 'src/services/wordpress.service.ts' --exclude 'src/services/sitecore.service.ts'" # Include only contentful services
16+
RSYNC_WORDPRESS_API_SRC_SERVICES_EXCLUDES: "--exclude 'src/services/contentful/' --exclude 'src/services/contentful.service.ts' --exclude 'src/services/sitecore.service.ts'" # Include only wordpress services
17+
RSYNC_SITECORE_UPLOAD_API_SRC_EXCLUDES: "--exclude 'migration-contentful/' --exclude 'migration-wordpress/' --exclude 'controllers/wordpress/' --exclude 'models/contentful.json' --exclude 'models/wordpress.json' --exclude 'services/contentful/' --exclude 'validators/aem/' --exclude 'validators/contentful/' --exclude 'validators/wordpress/'" # Include only sitecore upload-api
18+
RSYNC_CONTENTFUL_UPLOAD_API_SRC_EXCLUDES: "--exclude 'migration-sitecore/' --exclude 'migration-wordpress/' --exclude 'controllers/sitecore/' --exclude 'models/wordpress.json' --exclude 'validators/aem/' --exclude 'validators/sitecore/' --exclude 'validators/wordpress/'" # Include only contentful upload-api
19+
RSYNC_WORDPRESS_UPLOAD_API_SRC_EXCLUDES: "--exclude 'migration-sitecore/' --exclude 'migration-contentful/' --exclude 'controllers/sitecore/' --exclude 'models/contentful.json' --exclude 'validators/aem/' --exclude 'validators/sitecore/' --exclude 'validators/contentful/'" # Include only wordpress upload-api
920
jobs:
1021
sync-on-merge:
1122
runs-on: ubuntu-latest
1223

1324
permissions:
14-
contents: write
15-
pull-requests: write
25+
contents: write
26+
pull-requests: write
1627

1728
steps:
18-
- name: Check if PR was merged
19-
id: check_merge
20-
run: |
21-
if [ "${{ github.event.pull_request.merged }}" = "true" ]; then
22-
echo "PR was merged. Proceeding with sync."
23-
echo "merged=true" >> $GITHUB_ENV
24-
else
25-
echo "PR was closed without merging. Skipping sync."
26-
echo "merged=false" >> $GITHUB_ENV
27-
fi
28-
shell: bash
29+
- name: Check if PR was merged
30+
id: check_merge
31+
run: |
32+
if [ "${{ github.event.pull_request.merged }}" = "true" ]; then
33+
echo "PR was merged. Proceeding with sync."
34+
echo "merged=true" >> $GITHUB_ENV
35+
else
36+
echo "PR was closed without merging. Skipping sync."
37+
echo "merged=false" >> $GITHUB_ENV
38+
fi
39+
shell: bash
2940

30-
- name: Checkout migration-v2
31-
if: env.merged == 'true'
32-
uses: actions/checkout@v4
33-
with:
34-
fetch-depth: 0 # Fetch full history to compare changes
41+
- name: Checkout migration-v2
42+
if: env.merged == 'true'
43+
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0 # Fetch full history to compare changes
3546

36-
- name: Detect changed files
37-
if: env.merged == 'true'
38-
id: file_changes
39-
uses: dorny/paths-filter@v3
40-
with:
41-
filters: |
42-
api:
43-
- 'api/**'
44-
cli:
45-
- 'cli/**'
46-
ui:
47-
- 'ui/**'
48-
upload-api:
49-
- 'upload-api/src/**'
50-
migration-sitecore:
51-
- 'upload-api/migration-sitecore/**'
52-
migration-contentful:
53-
- 'upload-api/migration-contentful/**'
47+
- name: Detect changed files
48+
if: env.merged == 'true'
49+
id: file_changes
50+
uses: dorny/paths-filter@v3
51+
with:
52+
filters: |
53+
api:
54+
- 'api/**'
55+
cli:
56+
- 'cli/**'
57+
ui:
58+
- 'ui/**'
59+
upload-api:
60+
- 'upload-api/**'
61+
index:
62+
- 'index.js'
5463
55-
- name: Setup Git
56-
if: env.merged == 'true'
57-
run: |
58-
git config --global user.name "github-actions"
59-
git config --global user.email "[email protected]"
64+
- name: Setup Git
65+
if: env.merged == 'true'
66+
run: |
67+
git config --global user.name "github-actions"
68+
git config --global user.email "[email protected]"
6069
61-
- name: Sync changes to sitecore-repo (if applicable)
62-
if: env.merged == 'true' && (steps.file_changes.outputs.api == 'true' || steps.file_changes.outputs.cli == 'true' || steps.file_changes.outputs.ui == 'true' || steps.file_changes.outputs.upload-api == 'true' || steps.file_changes.outputs.migration-sitecore == 'true')
63-
run: |
64-
git clone https://x-access-token:${{ secrets.GH_PAT }}@github.com/contentstack-expert-services/migration-tool-sitecore.git
65-
cd migration-tool-sitecore
66-
git checkout -b sync-from-migration-v2-${{ github.event.pull_request.number }}
67-
rsync -av --delete ../api/ ./api/
68-
rsync -av --delete ../cli/ ./cli/
69-
rsync -av --delete ../ui/ ./ui/
70-
rsync -av --delete ../upload-api/src ./upload-api/src
71-
rsync -av --delete ../upload-api/migration-sitecore ./upload-api/migration-sitecore
72-
git add .
73-
git commit -m "Sync changes from migration-v2 PR #${{ github.event.pull_request.number }}"
74-
git push origin sync-from-migration-v2-${{ github.event.pull_request.number }}
70+
- name: Sync changes to sitecore-repo (if applicable)
71+
if: |
72+
env.merged == 'true' &&
73+
(
74+
steps.file_changes.outputs.api == 'true' ||
75+
steps.file_changes.outputs.cli == 'true' ||
76+
steps.file_changes.outputs.ui == 'true' ||
77+
steps.file_changes.outputs.upload-api == 'true' ||
78+
steps.file_changes.outputs.index == 'true'
79+
)
80+
run: |
81+
git clone https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ env.SITECORE_REPO }}.git
82+
cd migration-tool-sitecore
83+
git checkout -b sync-from-migration-v2-${{ github.event.pull_request.number }}
84+
rsync -av --delete ${{ env.RSYNC_SITECORE_API_SRC_SERVICES_EXCLUDES }} ../api/ ./api/
85+
rsync -av --delete ../cli/ ./cli/
86+
rsync -av --delete ../ui/ ./ui/
87+
rsync -av --delete ${{ env.RSYNC_SITECORE_UPLOAD_API_SRC_EXCLUDES }} ../upload-api/ ./upload-api/
88+
git add .
89+
git commit -m "Sync changes from migration-v2 PR #${{ github.event.pull_request.number }}"
90+
git push origin sync-from-migration-v2-${{ github.event.pull_request.number }}
7591
76-
- name: Create PR in sitecore-repo
77-
if: env.merged == 'true' && (steps.file_changes.outputs.api == 'true' || steps.file_changes.outputs.cli == 'true' || steps.file_changes.outputs.ui == 'true' || steps.file_changes.outputs.upload-api == 'true' || steps.file_changes.outputs.migration-sitecore == 'true')
78-
run: |
79-
gh pr create --repo contentstack-expert-services/migration-tool-sitecore \
80-
--title "Sync changes from migration-v2 PR #${{ github.event.pull_request.number }}" \
81-
--body "This PR syncs changes from migration-v2:\n${{ github.event.pull_request.html_url }}" \
82-
--head sync-from-migration-v2-${{ github.event.pull_request.number }} \
83-
--base main
84-
env:
85-
GH_TOKEN: ${{ secrets.GH_PAT }}
92+
- name: Create PR in sitecore-repo
93+
if: |
94+
env.merged == 'true' &&
95+
(
96+
steps.file_changes.outputs.api == 'true' ||
97+
steps.file_changes.outputs.cli == 'true' ||
98+
steps.file_changes.outputs.ui == 'true' ||
99+
steps.file_changes.outputs.upload-api == 'true' ||
100+
steps.file_changes.outputs.index == 'true'
101+
)
102+
run: |
103+
gh pr create --repo ${{ env.SITECORE_REPO }} \
104+
--title "Sync changes from migration-v2 PR #${{ github.event.pull_request.number }}" \
105+
--body "This PR syncs changes from migration-v2:\n${{ github.event.pull_request.html_url }}" \
106+
--head sync-from-migration-v2-${{ github.event.pull_request.number }} \
107+
--base ${{ env.BRANCH }}
108+
env:
109+
GH_TOKEN: ${{ secrets.GH_PAT }}
110+
111+
- name: Sync changes to wordpress-repo (if applicable)
112+
if: |
113+
env.merged == 'true' &&
114+
(
115+
steps.file_changes.outputs.api == 'true' ||
116+
steps.file_changes.outputs.cli == 'true' ||
117+
steps.file_changes.outputs.ui == 'true' ||
118+
steps.file_changes.outputs.upload-api == 'true' ||
119+
steps.file_changes.outputs.index == 'true'
120+
)
121+
run: |
122+
git clone https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ env.CONTENTFUL_REPO }}.git
123+
cd migration-tool-contentful
124+
git checkout -b sync-from-migration-v2-${{ github.event.pull_request.number }}
125+
rsync -av --delete ${{ env.RSYNC_CONTENTFUL_API_SRC_SERVICES_EXCLUDES }} ../api/ ./api/
126+
rsync -av --delete ../cli/ ./cli/
127+
rsync -av --delete ../ui/ ./ui/
128+
rsync -av --delete ${{ env.RSYNC_CONTENTFUL_UPLOAD_API_SRC_EXCLUDES }} ../upload-api/ ./upload-api/
129+
git add .
130+
git commit -m "Sync changes from migration-v2 PR #${{ github.event.pull_request.number }}"
131+
git push origin sync-from-migration-v2-${{ github.event.pull_request.number }}
132+
133+
- name: Create PR in contentful-repo
134+
if: |
135+
env.merged == 'true' &&
136+
(
137+
steps.file_changes.outputs.api == 'true' ||
138+
steps.file_changes.outputs.cli == 'true' ||
139+
steps.file_changes.outputs.ui == 'true' ||
140+
steps.file_changes.outputs.upload-api == 'true' ||
141+
steps.file_changes.outputs.index == 'true'
142+
)
143+
run: |
144+
gh pr create --repo ${{ env.CONTENTFUL_REPO }} \
145+
--title "Sync changes from migration-v2 PR #${{ github.event.pull_request.number }}" \
146+
--body "This PR syncs changes from migration-v2:\n${{ github.event.pull_request.html_url }}" \
147+
--head sync-from-migration-v2-${{ github.event.pull_request.number }} \
148+
--base ${{ env.BRANCH }}
149+
env:
150+
GH_TOKEN: ${{ secrets.GH_PAT }}
151+
152+
- name: Sync changes to wordpress-repo (if applicable)
153+
if: |
154+
env.merged == 'true' &&
155+
(
156+
steps.file_changes.outputs.api == 'true' ||
157+
steps.file_changes.outputs.cli == 'true' ||
158+
steps.file_changes.outputs.ui == 'true' ||
159+
steps.file_changes.outputs.upload-api == 'true' ||
160+
steps.file_changes.outputs.index == 'true'
161+
)
162+
run: |
163+
git clone https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ env.WORDPRESS_REPO }}.git
164+
cd migration-tool-wordpress
165+
git checkout -b sync-from-migration-v2-${{ github.event.pull_request.number }}
166+
rsync -av --delete ${{ env.RSYNC_WORDPRESS_API_SRC_SERVICES_EXCLUDES }} ../api/ ./api/
167+
rsync -av --delete ../cli/ ./cli/
168+
rsync -av --delete ../ui/ ./ui/
169+
rsync -av --delete ${{ env.RSYNC_WORDPRESS_UPLOAD_API_SRC_EXCLUDES }} ../upload-api/ ./upload-api/
170+
git add .
171+
git commit -m "Sync changes from migration-v2 PR #${{ github.event.pull_request.number }}"
172+
git push origin sync-from-migration-v2-${{ github.event.pull_request.number }}
173+
174+
- name: Create PR in wordpress-repo
175+
if: |
176+
env.merged == 'true' &&
177+
(
178+
steps.file_changes.outputs.api == 'true' ||
179+
steps.file_changes.outputs.cli == 'true' ||
180+
steps.file_changes.outputs.ui == 'true' ||
181+
steps.file_changes.outputs.upload-api == 'true' ||
182+
steps.file_changes.outputs.index == 'true'
183+
)
184+
run: |
185+
gh pr create --repo ${{ env.WORDPRESS_REPO }} \
186+
--title "Sync changes from migration-v2 PR #${{ github.event.pull_request.number }}" \
187+
--body "This PR syncs changes from migration-v2:\n${{ github.event.pull_request.html_url }}" \
188+
--head sync-from-migration-v2-${{ github.event.pull_request.number }} \
189+
--base ${{ env.BRANCH }}
190+
env:
191+
GH_TOKEN: ${{ secrets.GH_PAT }}

api/src/services/contentful.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,9 @@ const processField = (
331331
break;
332332
}
333333
}
334+
335+
336+
334337
};
335338

336339
// Helper function to clean up brackets in non-numeric lang_value

api/src/services/contentful/jsonRTE.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ function parseBlockAsset(obj: any, lang?: LangType, destination_stack_id?: Stack
314314
};
315315
}
316316

317+
318+
319+
317320
function parseBlockquote(obj: any): any {
318321
const children = obj.content.map((e: any) => parsers.get(e.nodeType)?.(e)).filter(Boolean);
319322
return {

api/src/services/sitecore.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import customLogger from '../utils/custom-logger.utils.js';
1212

1313
const append = "a";
1414

15+
1516
const baseDirName = MIGRATION_DATA_CONFIG.DATA
1617
const {
1718
ENTRIES_DIR_NAME,

api/src/services/wordpress.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const { JSDOM } = jsdom;
1515
const virtualConsole = new jsdom.VirtualConsole();
1616
// Get the current file's path
1717
const __filename = fileURLToPath(import.meta.url);
18+
19+
20+
1821
// Get the current directory
1922
const __dirname = path.dirname(__filename);
2023

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const envContents = {
3333
'Upload-API': uploadAPIEnvContent,
3434
};
3535

36+
3637
// Function to create env files
3738
const createEnvFiles = () => {
3839
// Loop through each key in the envFilePaths object

upload-api/.DS_Store

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

upload-api/migration-contentful/config/index.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
"contentful": "contentfulSchema"
55
},
66
"fileName": "en-us.json"
7+
8+
9+
710
}

upload-api/migration-sitecore/constants/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ const MIGRATION_DATA_CONFIG = {
4040
GLOBAL_FIELDS_FILE: "globalfields",
4141
GLOBAL_FIELDS_FILE_NAME : "globalfields.json",
4242

43-
44-
4543
EXPORT_INFO_FILE: "export-info.json"
4644
}
45+
46+
47+
4748
module.exports = {
4849
MIGRATION_DATA_CONFIG
4950
};

0 commit comments

Comments
 (0)