Files
china-dictatorship/push

79 lines
2.6 KiB
Plaintext
Raw Permalink Normal View History

2020-08-04 06:00:05 +00:00
#!/usr/bin/env bash
# https://github.com/cirosantilli/china-dictatorship#mirrors
set -eux
2021-07-27 12:12:27 +01:00
2021-09-14 09:51:18 +01:00
echo $#
if [ $# -gt 0 ]; then
dry_run=true
else
dry_run=false
fi
2020-08-04 06:00:05 +00:00
make
2021-07-27 12:12:27 +01:00
make multipage
2021-09-12 15:41:28 +01:00
if ! $dry_run; then
git push --follow-tags
2022-02-07 13:08:22 +00:00
git push -f git@github.com:cirosantilli/china-dictatorship-2.git &
git push -f git@gitlab.com:cirosantilli/china-dictatorship.git &
2022-08-04 03:01:35 +00:00
git push -f git@github.com:R7w726fYrfritM7zPJCO/cihna-dictatorshrip-8.git &
2022-08-02 02:00:46 +00:00
git push -f git@gitlab.binets.fr:ciro.duran-santilli/china-dictatorship.git &
2021-09-12 15:41:28 +01:00
wait
fi
2020-08-04 06:00:05 +00:00
2021-07-27 12:18:04 +01:00
out_dir=out
2021-07-27 12:12:27 +01:00
out_multipage_dir="${out_dir}/multipage"
2021-09-12 15:41:28 +01:00
function multipage-fixup() (
# Ain't nobody got time for Ruby coding!!!
# https://github.com/owenh000/asciidoctor-multipage/issues/20
# https://github.com/owenh000/asciidoctor-multipage/issues/21
# https://github.com/owenh000/asciidoctor-multipage/issues/22
find "$1" -name '*.html' ! -name 'index.html' | xargs perl -lapi -e '
2021-09-14 09:51:18 +01:00
s/<h[2-6] id="/<h2 id="/g;
2021-09-12 17:08:55 +01:00
s/href="README.html"/href="index-split"/g;
s/(href="(?![^"]+:\/\/)[^"]+).html(#[^"]*)?"/\1\2"/g;
2021-09-12 15:41:28 +01:00
'
2021-09-12 17:08:55 +01:00
# Not possible, it is identical to other lists actually...
# s/(<div class="paragraph nav-footer">)/<h2>Table of contents<\/h2>\1/g;
2021-09-12 15:41:28 +01:00
)
2020-08-04 06:00:05 +00:00
# GitHub pages.
# One time initial setup.
# git checkout --orphan gh-pages
# and copy over https://github.com/cirosantilli/jekyll-min
2021-07-27 12:12:27 +01:00
gh_pages_dir="${out_dir}/gh-pages"
2020-08-04 06:00:05 +00:00
if [ ! -d "$gh_pages_dir" ]; then
mkdir -p "$gh_pages_dir"
2021-04-28 08:00:07 +00:00
git clone --branch gh-pages --depth 1 "$(git remote get-url origin)" "$gh_pages_dir"
2020-08-04 06:00:05 +00:00
fi
cp README.html "${gh_pages_dir}/index.html"
2021-07-27 12:12:27 +01:00
cp "${out_multipage_dir}/"* "$gh_pages_dir"
mv "${gh_pages_dir}/README.html" "${gh_pages_dir}/index-split.html"
2021-09-12 15:41:28 +01:00
multipage-fixup "$gh_pages_dir"
if ! $dry_run; then
git -C "$gh_pages_dir" add .
if git -C "$gh_pages_dir" commit -m "$(git log -1 --format="%H")"; then
2021-09-12 17:10:57 +01:00
git -C "$gh_pages_dir" push -f
2021-09-12 15:41:28 +01:00
fi
2021-04-28 13:00:12 +00:00
fi
# GitLab pages
2021-06-07 11:22:15 +01:00
gl_pages_dir="${out_dir}/gl-pages"
2021-07-27 12:14:58 +01:00
gl_pages_public_dir="${gl_pages_dir}/public"
2021-04-28 13:00:12 +00:00
if [ ! -d "$gl_pages_dir" ]; then
2021-06-07 11:22:15 +01:00
mkdir -p "${out_dir}"
git clone --branch gl-pages --depth 1 git@gitlab.com:cirosantilli/china-dictatorship.git "$gl_pages_dir"
2021-04-28 13:00:12 +00:00
fi
2021-07-27 12:14:58 +01:00
make MEDIA=https://gitlab.com/cirosantilli/china-dictatorship-media/-/raw/master OUT="${gl_pages_public_dir}/index.html"
2021-04-28 13:00:12 +00:00
cp .gitlab-ci.yml "${gl_pages_dir}"
2021-07-27 12:14:58 +01:00
cp "${out_multipage_dir}/"* "$gl_pages_public_dir"
2021-07-27 13:12:09 +01:00
mv "${gl_pages_public_dir}/README.html" "${gl_pages_public_dir}/index-split.html"
2021-09-12 15:41:28 +01:00
multipage-fixup "$gl_pages_public_dir"
if ! $dry_run; then
git -C "$gl_pages_dir" add .
if git -C "$gl_pages_dir" commit -m "$(git log -1 --format="%H")"; then
2021-09-12 17:10:57 +01:00
git -C "$gl_pages_dir" push -f
2021-09-12 15:41:28 +01:00
fi
2020-08-04 06:00:05 +00:00
fi