milan jurkulák 2 éve
szülő
commit
c247f82b34

+ 5 - 4
.github/workflows/build-gradle-project.yml

@@ -76,8 +76,9 @@ jobs:
       # update wiki pages
       - name: Update wiki pages
         id: update_wiki_pages
-        uses: OrlovM/Wiki-Action@v1
-        with:
-          path: 'documentation'
-          token: ${{ secrets.TOKEN }}
+        run: ${{ github.action_path }}/update-wiki.sh
+        shell: bash
+        env:
+            WIKI_DIR: './documentation'
+            GH_TOKEN: ${{ secrets.TOKEN }}
 # done

+ 44 - 0
.github/workflows/update-wiki.sh

@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+#  Copyright (c) Milan Jurkulák 2024.
+#  Contact:
+#  e: mimoccc@gmail.com
+#  e: mj@mjdev.org
+#  w: https://mjdev.org
+#
+set -eu
+TEMP_REPO_DIR="wiki_action_$GITHUB_REPOSITORY$GITHUB_SHA"
+TEMP_WIKI_DIR="temp_wiki_$GITHUB_SHA"
+if [ -z "$WIKI_DIR" ]; then
+    echo "Wiki location is not specified, using default wiki/"
+    WIKI_DIR='wiki'
+fi
+if [ -z "$GH_TOKEN" ]; then
+    echo "Token is not specified"
+    exit 1
+fi
+# Clone wiki repo
+echo "Cloning wiki repo https://github.com/$GITHUB_REPOSITORY.wiki.git"
+cd "$TEMP_REPO_DIR"
+git clone "https://$GITHUB_ACTOR:$GH_TOKEN@github.com/$GITHUB_REPOSITORY.wiki.git" "$TEMP_WIKI_DIR"
+# Get commit details
+author=`git log -1 --format="%an"`
+email=`git log -1 --format="%ae"`
+message=`git log -1 --format="%s"`
+# Copy wikis
+echo "Copying edited wiki"
+cp -R "$WIKI_DIR/" "$TEMP_WIKI_DIR"
+# Changes check
+echo "Checking if wiki has changes"
+cd "$TEMP_WIKI_DIR"
+git config --local user.email "$email"
+git config --local user.name "$author"
+git add .
+if git diff-index --quiet HEAD; then
+  echo "Nothing changed"
+  exit 0
+fi
+# Push
+echo "Pushing changes to wiki"
+git commit -m "$message" && git push "https://$GITHUB_ACTOR:$GH_TOKEN@github.com/$GITHUB_REPOSITORY.wiki.git"
+# Done