diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..ca3932d --- /dev/null +++ b/.drone.yml @@ -0,0 +1,13 @@ +kind: pipeline +type: docker +name: default + +steps: +- name: Github + image: alpine/git + environment: + Github: + from_secret: Github + commands: + - chmod +x commit.sh + - ./commit.sh $Github diff --git a/commit.sh b/commit.sh new file mode 100644 index 0000000..ab4f3b2 --- /dev/null +++ b/commit.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# usage ./commit.sh https://username:password@git.domain.tld/username/repo.git +git clone $1 target +cd target + +git config user.email "10000@daihan.me" +git config user.name "Han Dai" + +wget https://gitea.dennx.com/api/v1/users/dennydai/heatmap -O heatmap +heatmap=$(cat heatmap | grep -Po [0-9]+) + +mkdir -p history + +column=0 # 0: timestamp, 1: # of contributions +for i in $heatmap +do + if [ $column = 0 ] # timestamp + then column=1 + timestamp=$i + else column=0 # # of contributions + synced=0 # synced # of contributions + if [ ! -f history/$timestamp ] + then echo "0" > history/$timestamp + else synced=$(cat history/$timestamp) + fi + + for j in $(seq $(expr $synced + 1) $i) + do + echo $j > history/$timestamp + git add . -A + export GIT_AUTHOR_DATE=$timestamp + export GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE + git commit -m "Sync Contribution Heatmap from Gitea" + done + fi +done + +git push -u origin master \ No newline at end of file