Browse Source

Initial commit

master
Han Dai 2 years ago
parent
commit
c36f1a3068
  1. 13
      .drone.yml
  2. 39
      commit.sh

13
.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

39
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
Loading…
Cancel
Save