-
Notifications
You must be signed in to change notification settings - Fork 206
42 lines (35 loc) · 1.02 KB
/
backup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Backup Main Branch
on:
push:
branches:
- main
jobs:
backup:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v2
with:
ref: main
- name: Create backup directory
run: mkdir -p backup
- name: Archive main branch as tar.gz
run: |
tar -czf backup/main_backup_$(date +"%Y%m%d").tar.gz *
working-directory: ${{ github.workspace }}
- name: Upload backup to Artifact
uses: actions/upload-artifact@v2
with:
name: backup
path: backup/main_backup_$(date +"%Y%m%d").tar.gz
- name: Set up Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "mgz0227"
- name: Create and push backup branch
run: |
git branch -D backup || true
git checkout -b backup
git add backup/main_backup_$(date +"%Y%m%d").tar.gz
git commit -m "Backup main branch as of $(date +"%Y-%m-%d")"
git push origin backup