update_wiki.sh 893 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. set -e
  3. if [[ $# != 2 ]]; then
  4. echo "Missing arguments"
  5. exit -1
  6. fi
  7. if [[ -z "$GITHUB_REPOSITORY" || -z "$GITHUB_TOKEN" || -z "$GITHUB_ACTOR" ]]; then
  8. echo "Missing environment"
  9. exit -1
  10. fi
  11. INPUTS="$1"
  12. TAGNAME="$2"
  13. WIKIPATH="tmp_wiki"
  14. WIKIFILE="Latest.md"
  15. git clone "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.wiki.git" "${WIKIPATH}"
  16. echo "# Latest Autobuilds" > "${WIKIPATH}/${WIKIFILE}"
  17. for f in "${INPUTS}"/*.txt; do
  18. VARIANT="$(basename "${f::-4}")"
  19. echo >> "${WIKIPATH}/${WIKIFILE}"
  20. echo "[${VARIANT}](https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAGNAME}/$(cat "${f}"))" >> "${WIKIPATH}/${WIKIFILE}"
  21. done
  22. cd "${WIKIPATH}"
  23. git config user.email "actions@github.com"
  24. git config user.name "Github Actions"
  25. git add "$WIKIFILE"
  26. git commit -m "Update latest version info"
  27. git push
  28. cd ..
  29. rm -rf "$WIKIPATH"