-
Notifications
You must be signed in to change notification settings - Fork 23
53 lines (45 loc) · 1.97 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
name: Mirror repo to S3
on:
schedule:
# Runs everyday at 12:25 am
- cron: '25 0 * * * '
workflow_dispatch:
jobs:
s3Backup:
runs-on: docker-builds
steps:
- uses: actions/checkout@v1
- name: Get info
id: get_info
run: |
GIT_COMMIT_DATE="$((`git log -n 1 --date-order --all | grep Date | awk '{ print $4 }'`))"
YESTERDAY_DATE="$((`date | awk '{ print $3 }'`-1))"
echo ::set-output name=GIT_COMMIT_DATE::${GIT_COMMIT_DATE}
echo ::set-output name=YESTERDAY_DATE::${YESTERDAY_DATE}
echo $GIT_COMMIT_DATE
echo $YESTERDAY_DATE
- name: Create backup
if: steps.get_info.outputs.GIT_COMMIT_DATE == steps.get_info.outputs.YESTERDAY_DATE
run: |
sudo apt update && sudo apt install python3-pip zip unzip -y
sudo pip3 install github-backup
sudo github-backup -O 0chain -P -t ${{ secrets.SVC_ACCOUNT_SECRET }} --output-directory=/github-backup/blobber --all -O -R blobber
- name: Create zip
if: steps.get_info.outputs.GIT_COMMIT_DATE == steps.get_info.outputs.YESTERDAY_DATE
run: sudo zip -r blobber.zip /github-backup/blobber
- name: Install AWS
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
- name: Set AWS credentials
if: steps.get_info.outputs.GIT_COMMIT_DATE == steps.get_info.outputs.YESTERDAY_DATE
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.BACKUP_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.BACKUP_SECRET_KEY_ID }}
aws-region: us-east-2
- name: Backup to s3
if: steps.get_info.outputs.GIT_COMMIT_DATE == steps.get_info.outputs.YESTERDAY_DATE
run: |
aws s3 cp blobber.zip s3://${{ secrets.MIRROR_TARGET }}/blobber.zip