Mirror repo to S3 #116
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: Mirror repo to S3 | |
on: | |
schedule: | |
# Runs everyday at 3:18 am | |
- cron: '18 3 * * * ' | |
workflow_dispatch: | |
jobs: | |
s3Backup: | |
runs-on: arc-runner | |
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 -y | |
sudo pip3 install github-backup | |
sudo github-backup -O 0chain -P -t ${{ secrets.ACCESS_TOKEN }} --output-directory=/github-backup/HelloWorld-Android --all -R HelloWorld-Android | |
- name: Create zip | |
if: steps.get_info.outputs.GIT_COMMIT_DATE == steps.get_info.outputs.YESTERDAY_DATE | |
run: sudo zip -r HelloWorld-Android.zip /github-backup/HelloWorld-Android | |
- 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.ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }} | |
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 HelloWorld-Android.zip s3://${{ secrets.MIRROR_TARGET }}/HelloWorld-Android.zip |