Created
November 15, 2024 07:47
-
-
Save atom-tr/be37caf56b67a4f3542385629a71d891 to your computer and use it in GitHub Desktop.
Sync 2 branches with some Exclusions paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync Branches with Exclusions | |
on: | |
workflow_dispatch: # Trigger the workflow manually | |
push: | |
branches: | |
- main | |
jobs: | |
sync-branches: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the repository | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch all history for all branches | |
token: ${{ secrets.ACCESS_TOKEN }} | |
# Step 2: Configure Git | |
- name: Configure Git | |
run: | | |
git config user.name "GitHub Action" | |
git config user.email "[email protected]" | |
# Step 3: Check out the target branch | |
- name: Check out mobile | |
run: git checkout mobile || git checkout -b mobile | |
# Step 4: Sync with branch2 while excluding paths | |
- name: Sync with branch2 (Exclude paths) | |
run: | | |
# Pull branch2 into branch1 | |
git fetch origin main | |
git merge origin/main --no-commit || true | |
# Remove excluded paths | |
git rm -r --cached .obsidian/plugins/ || true | |
rm -rf .obsidian/plugins/ | |
# Commit the changes | |
git commit -m "Synced mobile with main, excluding specific paths" || echo "No changes to commit" | |
# Step 5: Push changes | |
- name: Push changes to mobile | |
run: git push origin mobile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment