Update backup.yml #13
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: Backup main branch | |
on: | |
push: | |
branches: [main] | |
jobs: | |
backup_main_branch: | |
name: Backup main branch | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main branch | |
uses: actions/checkout@v2 | |
with: | |
ref: main | |
- name: Backup main branch as tar.gz | |
run: | | |
git archive --format=tar.gz --output=main_backup_$(date +"%Y%m%d%H%M%S").tar.gz main | |
mkdir -p backups | |
mv main_backup_*.tar.gz backups/ | |
shell: bash | |
- name: Push main branch backup to backup branch | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "mgz0227" | |
git remote add backup_origin https://github.com/mgz0227/legado-Harmony.git | |
git fetch backup_origin | |
git checkout -b backup_branch backup_origin/backup || git checkout -b backup_branch | |
mv backups/main_backup_*.tar.gz ./ | |
git add main_backup_*.tar.gz | |
git commit -m "Backup main branch at $(date)" | |
git push backup_origin backup_branch | |
git checkout main | |
shell: bash |