updated sync workflow #8
This file contains hidden or 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 to Python Repo | |
| on: | |
| 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: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Java Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| path: java-repo | |
| - name: Checkout Python Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: SikandarEjaz/RepoSyncTestPython | |
| token: ${{ secrets.SYNC_TOKEN }} | |
| path: python-repo | |
| - name: Sync files | |
| run: | | |
| # Copy files from Java repo to Python repo | |
| mkdir -p python-repo/synced-from-java | |
| if [ -d "java-repo/sync_folder" ] && [ "$(ls -A java-repo/sync_folder)" ]; then | |
| cp -r java-repo/sync_folder/* python-repo/synced-from-java/ | |
| else | |
| echo "sync_folder is empty or doesn't exist" | |
| fi | |
| - name: Commit and Push to Python Repo | |
| run: | | |
| cd python-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 "Sync from Java repo [automated]" | |
| git push |