Sync from Codeberg #5
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 from Codeberg | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 0 * * *" # runs daily at midnight (UTC) | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout current repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Clone public Codeberg repo (read-only) | |
| run: | | |
| git clone https://codeberg.org/ampmod/ampmod.git temp-src | |
| - name: Copy new or updated files (non-destructive) | |
| run: | | |
| rsync -av --ignore-existing temp-src/ . | |
| rsync -av --update temp-src/ . | |
| rm -rf temp-src | |
| - name: Commit each changed file individually | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| changed_files=$(git status --porcelain | awk '{print $2}') | |
| if [ -z "$changed_files" ]; then | |
| echo "No changes to commit" | |
| exit 0 | |
| fi | |
| for file in $changed_files; do | |
| git add "$file" | |
| git commit -m "Sync from Codeberg: update $file" || echo "No changes in $file" | |
| done | |
| - name: Push changes to develop branch | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Ensure we push to the current repo’s develop branch | |
| REPO_URL="https://github.com/${{ github.repository }}.git" | |
| git push "$REPO_URL" HEAD:develop |