tldr/scripts/deploy.sh

59 lines
1.6 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
2020-06-09 15:03:35 +01:00
# This script is executed by GitHub Actions when a PR is merged (i.e. in the `deploy` step).
set -ex
function initialize {
if [ -z "$TLDRHOME" ]; then
2020-06-09 15:03:35 +01:00
export TLDRHOME=${GITHUB_WORKSPACE:-$(pwd)}
fi
export TLDR_LANG_ARCHIVES_DIRECTORY="$TLDRHOME/language_archives"
export TLDR_ARCHIVE="tldr.zip"
export SITE_HOME="$HOME/site"
export SITE_REPO_SLUG="tldr-pages/tldr-pages.github.io"
# Configure git.
git config --global user.email "tldrbotgithub@gmail.com"
git config --global user.name "tldr bot"
git config --global push.default simple
git config --global diff.zip.textconv "unzip -c -a"
# Decrypt and add deploy key.
eval "$(ssh-agent -s)"
2020-06-24 13:30:09 +01:00
echo "${DEPLOY_KEY}"> id_ed25519
chmod 600 id_ed25519
ssh-add id_ed25519
}
function upload_assets {
git clone --quiet --depth 1 git@github.com:${SITE_REPO_SLUG}.git "$SITE_HOME"
mv -f "$TLDR_ARCHIVE" "$SITE_HOME/assets/"
mv -f "${TLDR_LANG_ARCHIVES_DIRECTORY}"/*.zip "$SITE_HOME/assets/"
rm -rf "$TLDR_LANG_ARCHIVES_DIRECTORY"
cp -f "$TLDRHOME/index.json" "$SITE_HOME/assets/"
scripts: build and deploy PDF pages for translations (#10846) * scrips: build and deploy PDF pages for all languages * cleanup/render.py: reformat code Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * Apply suggestions from code review Co-authored-by: Matthew Peveler <matt.peveler@gmail.com> * scrpts/pdf: update README, refactor code Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: building PDF was wildcard Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: building translations as wildcard 2 * test/ci: fix flag in PDF building Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: update build pdf action Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: extend PDF exclusion list Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * cleanup/ci: update PDF translation build Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * scripts/pdf: add website and repo link Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: move PDF build to seperate script file Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: minor fixes to build pdf script Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * cleanup/ci: update build PDF Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * scripts: update font family, minor fix Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * fix/deploy: sha256sum command Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> --------- Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> Co-authored-by: Matthew Peveler <matt.peveler@gmail.com>
2023-10-13 05:28:02 +01:00
cp -f "${TLDRHOME}/scripts/pdf/tldr-book*.pdf" "${SITE_HOME}/assets/"
sha256sum \
"${SITE_HOME}/assets/index.json" \
"${SITE_HOME}/assets/"*.zip \
scripts: build and deploy PDF pages for translations (#10846) * scrips: build and deploy PDF pages for all languages * cleanup/render.py: reformat code Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * Apply suggestions from code review Co-authored-by: Matthew Peveler <matt.peveler@gmail.com> * scrpts/pdf: update README, refactor code Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: building PDF was wildcard Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: building translations as wildcard 2 * test/ci: fix flag in PDF building Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: update build pdf action Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: extend PDF exclusion list Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * cleanup/ci: update PDF translation build Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * scripts/pdf: add website and repo link Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: move PDF build to seperate script file Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * test/ci: minor fixes to build pdf script Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * cleanup/ci: update build PDF Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * scripts: update font family, minor fix Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> * fix/deploy: sha256sum command Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> --------- Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com> Co-authored-by: Matthew Peveler <matt.peveler@gmail.com>
2023-10-13 05:28:02 +01:00
"${SITE_HOME}/assets/tldr-book*.pdf" \
> "${SITE_HOME}/assets/tldr.sha256sums"
2020-11-27 09:29:09 +00:00
cd "$SITE_HOME"
git add -A
git commit -m "[GitHub Actions] uploaded assets after commit tldr-pages/tldr@${GITHUB_SHA}"
git push -q
echo "Assets (pages archive, index) deployed to static site."
}
###################################
# MAIN
###################################
initialize
upload_assets