Skip to content

Commit deff746

Browse files
committed
workflow changes
1 parent 60aaba1 commit deff746

File tree

3 files changed

+169
-94
lines changed

3 files changed

+169
-94
lines changed

.github/workflows/repo-sync.yml

Lines changed: 169 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -8,109 +8,184 @@ on:
88

99
env:
1010
BRANCH : dev # Change this to your default branch if needed
11-
SITECORE_REPO: contentstack-expert-services/migration-tool-sitecore
12-
CONTENTFUL_REPO: contentstack-expert-services/migration-tool-contentful
13-
WORDPRESS_REPO: contentstack-expert-services/migration-tool-wordpress
14-
RSYNC_SITECORE_EXCLUDES: "--exclude 'src/services/contentful/' --exclude 'src/services/contentful.service.ts/' --exclude 'src/services/wordpress.service.ts/'" # Exclude contentful and wordpress services
15-
RSYNC_CONTENTFUL_EXCLUDES: "--exclude 'src/services/wordpress.service.ts/' --exclude 'src/services/sitecore.service.ts/'" # Exclude wordpress and sitecore services
16-
RSYNC_WORDPRESS_EXCLUDES: "--exclude 'src/services/contentful/' --exclude 'src/services/contentful.service.ts/' --exclude 'src/services/sitecore.service.ts/'" # Exclude contentful and sitecore services
17-
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
1820
jobs:
1921
sync-on-merge:
2022
runs-on: ubuntu-latest
2123

2224
permissions:
23-
contents: write
24-
pull-requests: write
25+
contents: write
26+
pull-requests: write
2527

2628
steps:
27-
- name: Check if PR was merged
28-
id: check_merge
29-
run: |
30-
if [ "${{ github.event.pull_request.merged }}" = "true" ]; then
31-
echo "PR was merged. Proceeding with sync."
32-
echo "merged=true" >> $GITHUB_ENV
33-
else
34-
echo "PR was closed without merging. Skipping sync."
35-
echo "merged=false" >> $GITHUB_ENV
36-
fi
37-
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
40+
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
46+
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'
63+
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]"
69+
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 $RSYNC_SITECORE_API_SRC_SERVICES_EXCLUDES ../api/ ./api/
85+
rsync -av --delete ../cli/ ./cli/
86+
rsync -av --delete ../ui/ ./ui/
87+
rsync -av --delete $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 }}
3891
39-
- name: Checkout migration-v2
40-
if: env.merged == 'true'
41-
uses: actions/checkout@v4
42-
with:
43-
fetch-depth: 0 # Fetch full history to compare changes
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 }}
44110

45-
- name: Detect changed files
46-
if: env.merged == 'true'
47-
id: file_changes
48-
uses: dorny/paths-filter@v3
49-
with:
50-
filters: |
51-
api:
52-
- 'api/**'
53-
cli:
54-
- 'cli/**'
55-
ui:
56-
- 'ui/**'
57-
upload-api:
58-
- 'upload-api/src/**'
59-
migration-sitecore:
60-
- 'upload-api/migration-sitecore/**'
61-
migration-contentful:
62-
- 'upload-api/migration-contentful/**'
63-
migration-wordpress:
64-
- 'upload-api/migration-wordpress/**'
65-
index:
66-
- 'index.js'
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 $RSYNC_CONTENTFUL_API_SRC_SERVICES_EXCLUDES ../api/ ./api/
126+
rsync -av --delete ../cli/ ./cli/
127+
rsync -av --delete ../ui/ ./ui/
128+
rsync -av --delete $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 }}
67132
68-
- name: Setup Git
69-
if: env.merged == 'true'
70-
run: |
71-
git config --global user.name "github-actions"
72-
git config --global user.email "[email protected]"
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 }}
73151

74-
- name: Sync changes to sitecore-repo (if applicable)
75-
if: |
76-
env.merged == 'true' &&
77-
(
78-
steps.file_changes.outputs.api == 'true' ||
79-
steps.file_changes.outputs.cli == 'true' ||
80-
steps.file_changes.outputs.ui == 'true' ||
81-
steps.file_changes.outputs.upload-api == 'true' ||
82-
steps.file_changes.outputs.migration-sitecore == 'true' ||
83-
steps.file_changes.outputs.index == 'true'
84-
)
85-
run: |
86-
git clone https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ env.SITECORE_REPO }}.git
87-
cd migration-tool-sitecore
88-
git checkout -b sync-from-migration-v2-${{ github.event.pull_request.number }}
89-
rsync -av --delete $RSYNC_SITECORE_EXCLUDES ../api/ ./api/
90-
rsync -av --delete ../cli/ ./cli/
91-
rsync -av --delete ../ui/ ./ui/
92-
rsync -av --delete ../upload-api/src ./upload-api/src
93-
rsync -av --delete ../upload-api/migration-sitecore ./upload-api/migration-sitecore
94-
git add .
95-
git commit -m "Sync changes from migration-v2 PR #${{ github.event.pull_request.number }}"
96-
git push origin sync-from-migration-v2-${{ github.event.pull_request.number }}
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 $RSYNC_WORDPRESS_API_SRC_SERVICES_EXCLUDES ../api/ ./api/
167+
rsync -av --delete ../cli/ ./cli/
168+
rsync -av --delete ../ui/ ./ui/
169+
rsync -av --delete $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 }}
97173
98-
- name: Create PR in sitecore-repo
99-
if: |
100-
env.merged == 'true' &&
101-
(
102-
steps.file_changes.outputs.api == 'true' ||
103-
steps.file_changes.outputs.cli == 'true' ||
104-
steps.file_changes.outputs.ui == 'true' ||
105-
steps.file_changes.outputs.upload-api == 'true' ||
106-
steps.file_changes.outputs.migration-sitecore == 'true' ||
107-
steps.file_changes.outputs.index == 'true'
108-
)
109-
run: |
110-
gh pr create --repo ${{ env.SITECORE_REPO }} \
111-
--title "Sync changes from migration-v2 PR #${{ github.event.pull_request.number }}" \
112-
--body "This PR syncs changes from migration-v2:\n${{ github.event.pull_request.html_url }}" \
113-
--head sync-from-migration-v2-${{ github.event.pull_request.number }} \
114-
--base ${{ env.BRANCH }}
115-
env:
116-
GH_TOKEN: ${{ secrets.GH_PAT }}
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 }}

upload-api/.DS_Store

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

0 commit comments

Comments
 (0)