Skip to content

Commit

Permalink
chore(cicd): New workflow to create/update main branch with master ch…
Browse files Browse the repository at this point in the history
…anges (#29867)

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 <[email protected]>
  • Loading branch information
nollymar and dcolina authored Sep 10, 2024
1 parent 9dea667 commit c50d421
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/cicd_post_sync-main-with-master.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
- 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

0 comments on commit c50d421

Please sign in to comment.