From c50d4213ab9fb0f9d42fbc935ee803d1cea60af6 Mon Sep 17 00:00:00 2001 From: Nollymar Longa Date: Tue, 10 Sep 2024 09:11:47 -0500 Subject: [PATCH] chore(cicd): New workflow to create/update main branch with master changes (#29867) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: #29840 ### Proposed Changes * Branch `main` is created if not exists * `main` is updated each time a PR gets merged into master --------- Co-authored-by: Daniel Enrique Colina Rodríguez --- .../cicd_post_sync-main-with-master.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/cicd_post_sync-main-with-master.yml diff --git a/.github/workflows/cicd_post_sync-main-with-master.yml b/.github/workflows/cicd_post_sync-main-with-master.yml new file mode 100644 index 000000000000..f0ed8396054b --- /dev/null +++ b/.github/workflows/cicd_post_sync-main-with-master.yml @@ -0,0 +1,39 @@ +## Temp workflow to keep the main branch synchronized with changes in master. +## This workflow will be deleted after finishing the migration from master to main. +## Epic: https://github.com/dotCMS/core/issues/29554 +name: Sync main with master + +on: + push: + branches: + - master + +jobs: + sync-main: + runs-on: ubuntu-latest + + steps: + - name: 'Setup git config' + run: | + git config user.name "${{ secrets.CI_MACHINE_USER }}" + git config user.email "dotCMS-Machine-User@dotcms.com" + + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for all branches + + - name: Create or update main branch + run: | + # Check if 'main' branch exists + if git show-ref --quiet refs/heads/main; then + # If 'main' branch exists, update it to match 'master' + git checkout main + git reset --hard origin/master + else + # If 'main' branch does not exist, create it from 'master' + git checkout -b main origin/master + fi + + # Push the updated main branch + git push origin main --force \ No newline at end of file