|
6 | 6 | branches: |
7 | 7 | - dev # Change this to your default branch if needed |
8 | 8 |
|
| 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 |
9 | 20 | jobs: |
10 | 21 | sync-on-merge: |
11 | 22 | runs-on: ubuntu-latest |
12 | 23 |
|
13 | 24 | permissions: |
14 | | - contents: write |
15 | | - pull-requests: write |
| 25 | + contents: write |
| 26 | + pull-requests: write |
16 | 27 |
|
17 | 28 | 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 |
29 | 40 |
|
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 |
35 | 46 |
|
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' |
54 | 63 |
|
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]" |
60 | 69 |
|
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 }} |
75 | 91 |
|
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 }} |
0 commit comments