Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions .github/workflows/sync-from-java.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: Sync from Java Repo (Manual)
name: Sync to Java Repo

on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'sync_folder/**' # Only trigger when files in sync_folder change. More foldes and files can be added later.
workflow_dispatch:

jobs:
sync:
Expand All @@ -11,24 +16,30 @@ jobs:
uses: actions/checkout@v4
with:
path: python-repo

- name: Checkout Java Repo
uses: actions/checkout@v4
with:
repository: SikandarEjaz/RepoSyncTestJava
token: ${{ secrets.SYNC_TOKEN }}
path: java-repo
- name: Sync files from Java

- name: Sync files
run: |
mkdir -p python-repo/synced-from-java
cp -r java-repo/sync_folder/* python-repo/synced-from-java/

- name: Commit and Push
# Copy files from Python repo to Java repo
mkdir -p java-repo/synced-from-python
# Check if sync_folder exists and has files
if [ -d "python-repo/sync_folder" ] && [ "$(ls -A python-repo/sync_folder)" ]; then
cp -r python-repo/sync_folder/* java-repo/synced-from-python/
else
echo "sync_folder is empty or doesn't exist"
fi

- name: Commit and Push to Java Repo
run: |
cd python-repo
cd java-repo
git config user.name "GitHub Action"
git config user.email "action@github.com"
git add .
git diff --quiet && git diff --staged --quiet || git commit -m "Manual sync from Java repo"
git push
git diff --quiet && git diff --staged --quiet || git commit -m "Sync from Python repo [automated]"
git push
1 change: 1 addition & 0 deletions sync_folder/PythonFile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a file in Python repo for testing synchronisation with the Java repo.
1 change: 1 addition & 0 deletions synced-from-java/AnotherFile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is another Text file for testing the synchronisation between the repositories.
1 change: 1 addition & 0 deletions synced-from-java/YetAnotherFile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is another file to test syncrinisation between Java-Python repo.
1 change: 1 addition & 0 deletions synced-from-java/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is atest foile for testing synchronisation bewteen Java and Pyhton repositories.