mirror of https://github.com/CrimsonTome/tldr.git
cleanup: revert back don't build scripts archive step (#11838)
Revert "Revert "scripts: don't build archives when pages haven't been changed" (#11837)"
This reverts commit 6aa6cd8659
.
pull/23/head
parent
6aa6cd8659
commit
68306bbf63
|
@ -14,14 +14,24 @@ function initialize {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export TLDR_ARCHIVE="tldr.zip"
|
export TLDR_ARCHIVE="tldr.zip"
|
||||||
|
DIFF="$(git diff --name-only @^ @ | cut -d'/' -f1)"
|
||||||
|
export DIFF
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_index {
|
function build_index {
|
||||||
|
if ! grep -xq "pages.*" <<< "$DIFF"; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
npm run build-index
|
npm run build-index
|
||||||
echo "Pages index successfully built."
|
echo "Pages index successfully built."
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_archive {
|
function build_archive {
|
||||||
|
if ! grep -xq "pages.*" <<< "$DIFF"; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
rm -f "$TLDR_ARCHIVE"
|
rm -f "$TLDR_ARCHIVE"
|
||||||
cd "$TLDRHOME/"
|
cd "$TLDRHOME/"
|
||||||
zip -q -r "$TLDR_ARCHIVE" pages* LICENSE.md index.json
|
zip -q -r "$TLDR_ARCHIVE" pages* LICENSE.md index.json
|
||||||
|
@ -29,19 +39,20 @@ function build_archive {
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_translation_archives {
|
function build_translation_archives {
|
||||||
local source_directory="$TLDRHOME"
|
local source_directory target_directory lang archive_name
|
||||||
local target_directory="$TLDR_LANG_ARCHIVES_DIRECTORY"
|
source_directory="$TLDRHOME"
|
||||||
|
target_directory="$TLDR_LANG_ARCHIVES_DIRECTORY"
|
||||||
mkdir -p "$target_directory"
|
mkdir -p "$target_directory"
|
||||||
rm -f "$target_directory"/*
|
rm -f "$target_directory"/*
|
||||||
|
|
||||||
for lang_dir in "$source_directory"/pages*; do
|
for lang_dir in "$source_directory"/pages*; do
|
||||||
# Skip symlinks (pages.en) and things that are not directories
|
lang=$(basename "$lang_dir")
|
||||||
if [[ ! -d $lang_dir || -h $lang_dir ]]; then
|
# Skip symlinks (pages.en), files outside pages* and directories that haven't been changed.
|
||||||
|
if [[ ! -d $lang_dir || -h $lang_dir ]] || ! grep -Fxq "$lang" <<< "$DIFF"; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local lang=$(basename "$lang_dir")
|
archive_name="tldr-$lang.zip"
|
||||||
local archive_name="tldr-$lang.zip"
|
|
||||||
|
|
||||||
# Create the zip archive
|
# Create the zip archive
|
||||||
|
|
||||||
|
@ -53,7 +64,9 @@ function build_translation_archives {
|
||||||
done
|
done
|
||||||
|
|
||||||
cd "$target_directory"
|
cd "$target_directory"
|
||||||
|
if grep -Fxq pages <<< "$DIFF"; then
|
||||||
cp tldr-pages.zip tldr-pages.en.zip
|
cp tldr-pages.zip tldr-pages.en.zip
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
|
|
|
@ -30,21 +30,26 @@ function initialize {
|
||||||
|
|
||||||
function upload_assets {
|
function upload_assets {
|
||||||
git clone --quiet --depth 1 git@github.com:${SITE_REPO_SLUG}.git "$SITE_HOME"
|
git clone --quiet --depth 1 git@github.com:${SITE_REPO_SLUG}.git "$SITE_HOME"
|
||||||
mv -f "$TLDR_ARCHIVE" "$SITE_HOME/assets/"
|
[[ -f "$TLDR_ARCHIVE" ]] && mv -f "$TLDR_ARCHIVE" "$SITE_HOME/assets/"
|
||||||
find "$TLDR_LANG_ARCHIVES_DIRECTORY" -maxdepth 1 -name "*.zip" -exec mv -f {} "$SITE_HOME/assets/" \;
|
find "$TLDR_LANG_ARCHIVES_DIRECTORY" -maxdepth 1 -name "*.zip" -exec mv -f {} "$SITE_HOME/assets/" \;
|
||||||
rm -rf "$TLDR_LANG_ARCHIVES_DIRECTORY"
|
rm -rf "$TLDR_LANG_ARCHIVES_DIRECTORY"
|
||||||
cp -f "$TLDRHOME/index.json" "$SITE_HOME/assets/"
|
[[ -f "$TLDRHOME/index.json" ]] && cp -f "$TLDRHOME/index.json" "$SITE_HOME/assets/"
|
||||||
find "$TLDR_PDF_FILES_DIRECTORY" -maxdepth 1 -name "*.pdf" -exec mv -f {} "$SITE_HOME/assets/" \;
|
find "$TLDR_PDF_FILES_DIRECTORY" -maxdepth 1 -name "*.pdf" -exec mv -f {} "$SITE_HOME/assets/" \;
|
||||||
rm -rf "$TLDR_PDF_FILES_DIRECTORY"
|
rm -rf "$TLDR_PDF_FILES_DIRECTORY"
|
||||||
|
|
||||||
cd "$SITE_HOME/assets"
|
cd "$SITE_HOME/assets"
|
||||||
sha256sum -- index.json *.zip > tldr.sha256sums
|
sha256sum -- index.json *.zip > tldr.sha256sums
|
||||||
|
|
||||||
|
# Check if there are changes before committing and pushing.
|
||||||
|
if git diff --quiet; then
|
||||||
|
echo "No changes to deploy."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
git add -A
|
git add -A
|
||||||
git commit -m "[GitHub Actions] uploaded assets after commit tldr-pages/tldr@${GITHUB_SHA}"
|
git commit -m "[GitHub Actions] uploaded assets after commit tldr-pages/tldr@${GITHUB_SHA}"
|
||||||
git push -q
|
git push -q
|
||||||
|
echo "Assets (pages archive, index and checksum) deployed to the static site."
|
||||||
echo "Assets (pages archive, index) deployed to static site."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
|
|
Loading…
Reference in New Issue