action-gitea-mirror/entrypoint.sh

56 lines
2.2 KiB
Bash
Raw Normal View History

2020-10-16 22:27:36 +08:00
#!/bin/sh
set -eu
2020-10-16 22:40:56 +08:00
gh_username="$INPUT_GH_USERNAME"
2020-10-17 09:32:45 +08:00
gh_accesstoken="$INPUT_GH_ACCESSTOKEN"
2020-10-16 22:40:56 +08:00
gitea_host="$INPUT_GITEA_HOST"
gitea_username="$INPUT_GITEA_USERNAME"
gitea_accesstoken="$INPUT_GITEA_ACCESSTOKEN"
gitea_gist_prefix="$INPUT_GITEA_GIST_PREFIX"
gitea_gist_surfix="$INPUT_GITEA_GIST_SURFIX"
gistsSource="$INPUT_GISTSSOURCE"
gistsStared="$INPUT_GISTSSTARED"
repositoryStared="$INPUT_REPOSITORYSTARED"
repositorySource="$INPUT_REPOSITORYSOURCE"
repositoryForked="$INPUT_REPOSITORYFORKED"
2020-10-16 22:27:36 +08:00
2020-10-17 09:32:45 +08:00
echo "###[group] Setting Up Gitea Mirror Script"
2020-10-16 23:13:02 +08:00
git clone https://github.com/varunsridharan/github-gitea-mirror ./mirror-handler
2020-10-16 23:59:35 +08:00
echo "###[endgroup]"
2020-10-16 23:13:02 +08:00
2020-10-16 23:55:41 +08:00
echo "🗳️ Updating Settings"
2020-10-16 23:09:33 +08:00
template='{"github":{"username":"%s","accesstoken":"%s"},"gitea":{"host":"%s","accesstoken":"%s","username":"%s","default_userpassword":"%s","gist":{"prefix":"%s","surfix":"%s"}},"repomap":{},"gistsSource":%s,"gistsStared":%s,"repositoryStared":%s,"repositorySource":%s,"repositoryForked":%s}'
2020-10-17 09:32:45 +08:00
json_string=$(printf "$template" "$gh_username" "$gh_accesstoken" "$gitea_host" "$gitea_accesstoken" "$gitea_username" "RY7VpBD62P7964c9mSz%2GAM82hv68yUbHc4@Gdw8c%f^W3*qdzof*8a6b^rKy" "$gitea_gist_prefix" "$gitea_gist_surfix" "$gistsSource" "$gistsStared" "$repositoryStared" "$repositorySource" "$repositoryForked")
2020-10-16 23:55:41 +08:00
echo "$json_string" >./mirror-handler/src/config.json
2020-10-16 23:13:02 +08:00
2020-10-16 23:35:54 +08:00
if [ "$gistsSource" == "true" ]; then
2020-10-16 23:55:41 +08:00
echo "###[group] ⏳ Setting Up Mirror For Public & Private Gits"
2020-10-16 23:35:54 +08:00
python3 ./mirror-handler/gist.py
2020-10-16 23:55:41 +08:00
echo "###[endgroup]"
fi
if [ "$gistsStared" == "true" ]; then
echo "###[group] ⏳ Setting Up Mirror For Stared Gits"
python3 ./mirror-handler/giststared.py
echo "###[endgroup]"
fi
if [ "$repositorySource" == "true" ]; then
echo "###[group] ⏳ Setting Up Mirror For Public & Private Source Repository"
python3 ./mirror-handler/repoSource.py
echo "###[endgroup]"
fi
if [ "$repositoryForked" == "true" ]; then
echo "###[group] ⏳ Setting Up Mirror For Forked Repository"
python3 ./mirror-handler/repoForked.py
echo "###[endgroup]"
fi
if [ "$repositoryStared" == "true" ]; then
echo "###[group] ⏳ Setting Up Mirror For Stared Repository"
python3 ./mirror-handler/repoStared.py
echo "###[endgroup]"
fi