commit
d646e62888
1 changed files with 25 additions and 24 deletions
|
@ -1,18 +1,19 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# BEARER_TOKEN=
|
# __MISSKEY_BEARER_TOKEN=
|
||||||
# CAMPAIGN_ID=
|
# __MISSKEY_CAMPAIGN_ID=
|
||||||
# GITHUB_TOKEN=
|
# __MISSKEY_GITHUB_TOKEN=
|
||||||
# HEAD='acid-chicken:patch-autogen'
|
# __MISSKEY_HEAD=acid-chicken:patch-autogen
|
||||||
# REPO='syuilo/misskey'
|
# __MISSKEY_REPO=syuilo/misskey
|
||||||
test "$(curl -LSs -w '\n' -- "https://api.github.com/repos/$REPO/pulls?access_token=$GITHUB_TOKEN" | jq -r '.[].head.label' | grep $HEAD)" && exit 1
|
# __MISSKEY_BRANCH=develop
|
||||||
|
test "$(curl -LSs -w '\n' -- "https://api.github.com/repos/$REPO/pulls?access_token=$__MISSKEY_GITHUB_TOKEN" | jq -r '.[].head.label' | grep $__MISSKEY_HEAD)" && exit 1
|
||||||
cd "$(dirname $0)/.." && \
|
cd "$(dirname $0)/.." && \
|
||||||
touch null.cache && \
|
touch null.cache && \
|
||||||
rm *.cache && \
|
rm *.cache && \
|
||||||
git checkout master && \
|
git checkout $__MISSKEY_BRANCH && \
|
||||||
git pull origin master && \
|
git pull origin $__MISSKEY_BRANCH && \
|
||||||
git pull upstream master && \
|
git pull upstream $__MISSKEY_BRANCH && \
|
||||||
git stash && \
|
git stash && \
|
||||||
git rebase -f upstream/master && \
|
git rebase -f upstream/$__MISSKEY_BRANCH && \
|
||||||
git branch patch-autogen && \
|
git branch patch-autogen && \
|
||||||
git checkout patch-autogen && \
|
git checkout patch-autogen && \
|
||||||
git reset --hard HEAD || \
|
git reset --hard HEAD || \
|
||||||
|
@ -20,12 +21,12 @@ exit 1
|
||||||
touch patreon.md.cache && \
|
touch patreon.md.cache && \
|
||||||
rm patreon.md.cache && \
|
rm patreon.md.cache && \
|
||||||
echo '<!-- PATREON_START -->' > patreon.md.cache && \
|
echo '<!-- PATREON_START -->' > patreon.md.cache && \
|
||||||
URL="https://www.patreon.com/api/oauth2/v2/campaigns/$CAMPAIGN_ID/members?include=currently_entitled_tiers,user&fields%5Btier%5D=title&fields%5Buser%5D=full_name,thumb_url,url,hide_pledges"
|
url="https://www.patreon.com/api/oauth2/v2/campaigns/$__MISSKEY_CAMPAIGN_ID/members?include=currently_entitled_tiers,user&fields%5Btier%5D=title&fields%5Buser%5D=full_name,thumb_url,url,hide_pledges"
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
touch patreon.raw.cache && \
|
touch patreon.raw.cache && \
|
||||||
rm patreon.raw.cache && \
|
rm patreon.raw.cache && \
|
||||||
curl -LSs -w '\n' -H "Authorization: Bearer $BEARER_TOKEN" -- $URL > patreon.raw.cache && \
|
curl -LSs -w '\n' -H "Authorization: Bearer $__MISSKEY_BEARER_TOKEN" -- $url > patreon.raw.cache && \
|
||||||
touch patreon.cache && \
|
touch patreon.cache && \
|
||||||
rm patreon.cache && \
|
rm patreon.cache && \
|
||||||
cat patreon.raw.cache | \
|
cat patreon.raw.cache | \
|
||||||
|
@ -42,31 +43,31 @@ while :
|
||||||
xargs -I% echo '<td><a href="%</a></td>' >> patreon.md.cache && \
|
xargs -I% echo '<td><a href="%</a></td>' >> patreon.md.cache && \
|
||||||
echo '</tr></table>' >> patreon.md.cache || \
|
echo '</tr></table>' >> patreon.md.cache || \
|
||||||
exit 1
|
exit 1
|
||||||
NEW_URL="$(cat patreon.raw.cache | jq -r '.links.next')"
|
new_url="$(cat patreon.raw.cache | jq -r '.links.next')"
|
||||||
test "$NEW_URL" = 'null' && \
|
test "$new_url" = 'null' && \
|
||||||
break || \
|
break || \
|
||||||
URL="$NEW_URL"
|
URL="$url"
|
||||||
done
|
done
|
||||||
IGNORE= && \
|
ignore= && \
|
||||||
echo -e "\n**Last updated:** $(date -uR | sed 's/\+0000/UTC/')\n<!-- PATREON_END -->" >> patreon.md.cache && \
|
echo -e "\n**Last updated:** $(date -uR | sed 's/\+0000/UTC/')\n<!-- PATREON_END -->" >> patreon.md.cache && \
|
||||||
touch README.md && \
|
touch README.md && \
|
||||||
touch .autogen/README.md && \
|
touch .autogen/README.md && \
|
||||||
rm .autogen/README.md && \
|
rm .autogen/README.md && \
|
||||||
mv README.md .autogen/README.md && \
|
mv README.md .autogen/README.md && \
|
||||||
cat .autogen/README.md | while IFS= read LINE;
|
cat .autogen/README.md | while IFS= read line;
|
||||||
do
|
do
|
||||||
if [[ -z "$IGNORE" ]]
|
if [[ -z "$ignore" ]]
|
||||||
then
|
then
|
||||||
if [[ "$LINE" = '<!-- PATREON_START -->' ]]
|
if [[ "$line" = '<!-- PATREON_START -->' ]]
|
||||||
then
|
then
|
||||||
IGNORE='PATREON_INSIDE'
|
ignore='PATREON_INSIDE'
|
||||||
else
|
else
|
||||||
echo "$LINE" >> README.md
|
echo "$line" >> README.md
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ "$LINE" = '<!-- PATREON_END -->' ]]
|
if [[ "$LINE" = '<!-- PATREON_END -->' ]]
|
||||||
then
|
then
|
||||||
IGNORE=
|
ignore=
|
||||||
cat patreon.md.cache >> README.md
|
cat patreon.md.cache >> README.md
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -80,7 +81,7 @@ test 4 -lt $(cat diff.cache | wc -l) && \
|
||||||
git add README.md && \
|
git add README.md && \
|
||||||
git commit -m 'Update README.md [AUTOGEN]' && \
|
git commit -m 'Update README.md [AUTOGEN]' && \
|
||||||
git push -f origin patch-autogen && \
|
git push -f origin patch-autogen && \
|
||||||
curl -LSs -w '\n' -X POST -d '{"title":"[AUTOMATED] Update README.md","body":"*This pull request was created by a tool.*","head":"'$HEAD'","base":"master"}' -- "https://api.github.com/repos/$REPO/pulls?access_token=$GITHUB_TOKEN"
|
curl -LSs -w '\n' -X POST -d '{"title":"[AUTOMATED] Update README.md","body":"*This pull request was created by a tool.*","head":"'$__MISSKEY_HEAD'","base":"'$__MISSKEY_BRANCH'"}' -- "https://api.github.com/repos/$__MISSKEY_REPO/pulls?access_token=$__MISSKEY_GITHUB_TOKEN"
|
||||||
git stash
|
git stash
|
||||||
git checkout master
|
git checkout $__MISSKEY_BRANCH
|
||||||
git branch -D patch-autogen
|
git branch -D patch-autogen
|
||||||
|
|
Loading…
Reference in a new issue