-
Notifications
You must be signed in to change notification settings - Fork 2
76 lines (55 loc) · 1.69 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Backup
on:
schedule:
- cron: '0 0 * * *' # UTC == 2 AM EET
workflow_dispatch:
jobs:
backup:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Backup repositories from GitHub
run: ${GITHUB_WORKSPACE}/backup.sh
env:
# PAT needs these scopes: read:org, repo
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GH_OWNER: ${{ github.repository_owner }}
#GH_LIST_LIMIT: 3
#- name: Debug - List backups
# run: ls -lah ${GITHUB_WORKSPACE}/backups/
- uses: actions/cache@v4
with:
path: backups
key: backups-${{ github.run_id }}
restore-keys: backups-
sync:
runs-on: ubuntu-latest
needs: [ backup ]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: backups
key: backups-${{ github.run_id }}
#- name: Debug - List backups
# run: ls -lah ${GITHUB_WORKSPACE}/backups/
- name: Sync backups to S3
run: ${GITHUB_WORKSPACE}/s3.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
S3_BUCKET: ${{ secrets.S3_BUCKET }}
ENDPOINT_URL: ${{ secrets.ENDPOINT_URL }}
cleanup:
runs-on: ubuntu-latest
needs: [ sync ]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Delete workflow runs and cache
run: ${GITHUB_WORKSPACE}/cleanup.sh
env:
GH_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}