diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75c3bb8d3..5c5c6818a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,7 @@ on: branches: - master - tiddlywiki-com + - multi-wiki-support env: NODE_VERSION: "22" jobs: @@ -82,3 +83,15 @@ jobs: - run: "./bin/build-tw-org.sh" env: GH_TOKEN: ${{ secrets.GITHUBPUSHTOKEN }} + build-mws-tiddlywiki-com: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/multi-wiki-support' + needs: test + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: "${{ env.NODE_VERSION }}" + - run: "./bin/build-mws-site.sh" + env: + GH_TOKEN: ${{ secrets.GITHUBPUSHTOKEN }} diff --git a/bin/build-mws-site.sh b/bin/build-mws-site.sh new file mode 100755 index 000000000..4f06c252f --- /dev/null +++ b/bin/build-mws-site.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +# Build mws.tiddlywiki.com assets. + +# Default to the version of TiddlyWiki installed in this repo + +if [ -z "$MWSTWCOM_BUILD_TIDDLYWIKI" ]; then + MWSTWCOM_BUILD_TIDDLYWIKI=./tiddlywiki.js +fi + +echo "Using MWSTWCOM_BUILD_TIDDLYWIKI as [$MWSTWCOM_BUILD_TIDDLYWIKI]" + +# Set up the build details + +if [ -z "$MWSTWCOM_BUILD_DETAILS" ]; then + MWSTWCOM_BUILD_DETAILS="$(git symbolic-ref --short HEAD)-$(git rev-parse HEAD) from $(git remote get-url origin)" +fi + +echo "Using MWSTWCOM_BUILD_DETAILS as [$MWSTWCOM_BUILD_DETAILS]" + +if [ -z "$MWSTWCOM_BUILD_COMMIT" ]; then + MWSTWCOM_BUILD_COMMIT="$(git rev-parse HEAD)" +fi + +echo "Using MWSTWCOM_BUILD_COMMIT as [$MWSTWCOM_BUILD_COMMIT]" + +# Set up the build output directory + +if [ -z "$MWSTWCOM_BUILD_OUTPUT" ]; then + MWSTWCOM_BUILD_OUTPUT=$(mktemp -d) +fi + +mkdir -p $MWSTWCOM_BUILD_OUTPUT + +if [ ! -d "$MWSTWCOM_BUILD_OUTPUT" ]; then + echo 'A valid MWSTWCOM_BUILD_OUTPUT environment variable must be set' + exit 1 +fi + +echo "Using MWSTWCOM_BUILD_OUTPUT as [$MWSTWCOM_BUILD_OUTPUT]" + +# Pull existing GitHub pages content + +git clone --depth=1 --branch=main "https://github.com/TiddlyWiki/mws.tiddlywiki.com-gh-pages.git" $MWSTWCOM_BUILD_OUTPUT + +# Make the CNAME file that GitHub Pages requires + +echo "mws.tiddlywiki.com" > $MWSTWCOM_BUILD_OUTPUT/CNAME + +# Delete any existing static content + +mkdir -p $MWSTWCOM_BUILD_OUTPUT/static +rm $MWSTWCOM_BUILD_OUTPUT/static/* + +# Put the build details into a .tid file so that it can be included in each build (deleted at the end of this script) + +echo -e -n "title: $:/build\ncommit: $MWSTWCOM_BUILD_COMMIT\n\n$MWSTWCOM_BUILD_DETAILS\n" > $MWSTWCOM_BUILD_OUTPUT/build.tid + +###################################################### +# +# mws.tiddlywiki.com distribution +# +###################################################### + +# /index.html Main site +# /favicon.ico Favicon for main site +# /static.html Static rendering of default tiddlers +# /alltiddlers.html Static rendering of all tiddlers +# /static/* Static single tiddlers +# /static/static.css Static stylesheet +# /static/favicon.ico Favicon for static pages +node $MWSTWCOM_BUILD_TIDDLYWIKI \ + editions/multiwikidocs \ + --verbose \ + --version \ + --load $MWSTWCOM_BUILD_OUTPUT/build.tid \ + --output $MWSTWCOM_BUILD_OUTPUT \ + --build favicon static index \ + || exit 1 + +# Delete the temporary build tiddler + +rm $MWSTWCOM_BUILD_OUTPUT/build.tid || exit 1 + +# Push output back to GitHub + +# Exit script immediately if any command fails +set -e + +pushd $MWSTWCOM_BUILD_OUTPUT +git config --global user.email "actions@github.com" +git config --global user.name "GitHub Actions" +git add -A . +git commit --message "GitHub build: $GITHUB_RUN_NUMBER of $TW5_BUILD_BRANCH ($(date +'%F %T %Z'))" +git remote add deploy "https://$GH_TOKEN@github.com/TiddlyWiki/mws.tiddlywiki.com-gh-pages.git" &>/dev/null +git push deploy main &>/dev/null +popd diff --git a/editions/multiwikidocs/tiddlers/DefaultTiddlers.tid b/editions/multiwikidocs/tiddlers/DefaultTiddlers.tid new file mode 100644 index 000000000..a3c362aff --- /dev/null +++ b/editions/multiwikidocs/tiddlers/DefaultTiddlers.tid @@ -0,0 +1,3 @@ +title: $:/DefaultTiddlers + +HelloThere \ No newline at end of file diff --git a/editions/multiwikidocs/tiddlers/HelloThere.tid b/editions/multiwikidocs/tiddlers/HelloThere.tid new file mode 100644 index 000000000..778391586 --- /dev/null +++ b/editions/multiwikidocs/tiddlers/HelloThere.tid @@ -0,0 +1,3 @@ +title: HelloThere + +Hello! This is a test \ No newline at end of file diff --git a/editions/multiwikidocs/tiddlywiki.info b/editions/multiwikidocs/tiddlywiki.info new file mode 100644 index 000000000..4bdee1d3f --- /dev/null +++ b/editions/multiwikidocs/tiddlywiki.info @@ -0,0 +1,23 @@ +{ + "description": "Multiple wiki server documentation edition", + "plugins": [ + ], + "themes": [ + "tiddlywiki/vanilla", + "tiddlywiki/snowwhite" + ], + "build": { + "index": [ + "--savetiddlers","[tag[external-image]]","images", + "--setfield","[tag[external-image]]","_canonical_uri","$:/core/templates/canonical-uri-external-image","text/plain", + "--setfield","[tag[external-image]]","text","","text/plain", + "--render","$:/core/save/all","index.html","text/plain"], + "favicon": [ + "--savetiddler","$:/favicon.ico","favicon.ico"], + "static": [ + "--render","$:/core/templates/static.template.html","static.html","text/plain", + "--render","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain", + "--render","[!is[system]]","[encodeuricomponent[]addprefix[static/]addsuffix[.html]]","text/plain","$:/core/templates/static.tiddler.html", + "--render","$:/core/templates/static.template.css","static/static.css","text/plain"] + } +}