update-from-remote-theme #12
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
| # File: .github/workflows/update-from-remote-theme.yml | |
| name: Update from Remote Theme Repository | |
| on: | |
| repository_dispatch: | |
| types: [update-from-remote-theme] | |
| workflow_dispatch: | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout macromanagers repository | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Checkout remote-theme repository | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: korenmiklos/remote-theme | |
| path: temp-remote | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| - name: Install dependencies | |
| run: pip install PyYAML | |
| - name: Clean existing files | |
| run: | | |
| # List of directories to clean | |
| dirs_to_clean=("_posts" "_publications" "_courses" "_datasets" "_events" "_software" "_data") | |
| for dir in "${dirs_to_clean[@]}"; do | |
| if [ -e "$dir" ]; then | |
| git rm -rf "$dir" | |
| echo "Removed $dir from Git tracking" | |
| fi | |
| done | |
| - name: Filter and copy files | |
| run: | | |
| python3 copy_files.py | |
| - name: Remove temp folder | |
| run: rm -rf temp-remote | |
| - name: Commit and push changes | |
| run: | | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| # Configure git to allow rebase | |
| git config pull.rebase false | |
| # Set up remote with token | |
| git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY | |
| git add . | |
| git commit -m "Update from remote theme repository" || echo "No changes to commit" | |
| # Pull changes from remote and merge | |
| git pull origin main | |
| # Push changes | |
| git push | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |