action-details-check.yml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. # This action will check that LinuxGSM is picking up game server config and parameter variables.
  2. name: Details Check
  3. on:
  4. workflow_dispatch:
  5. push:
  6. branches:
  7. - develop
  8. pull_request:
  9. branches:
  10. - develop
  11. permissions:
  12. contents: read
  13. concurrency:
  14. group: details-check-${{ github.ref_name }}
  15. cancel-in-progress: true
  16. jobs:
  17. create-matrix:
  18. if: github.repository_owner == 'GameServerManagers'
  19. runs-on: ubuntu-latest
  20. env:
  21. LGSM_REF: ${{ github.event.pull_request.head.sha || github.ref_name }}
  22. outputs:
  23. matrix: ${{ steps.set-matrix.outputs.matrix }}
  24. steps:
  25. - name: Checkout
  26. uses: actions/checkout@v6
  27. with:
  28. # Full history so the base branch ref is available for the
  29. # `git diff origin/<base>...HEAD` comparison below (a shallow
  30. # checkout has no origin/<base> and the diff fails).
  31. fetch-depth: 0
  32. - name: Detect targeted servers (PR only)
  33. id: targeted
  34. if: github.event_name == 'pull_request'
  35. run: |
  36. changed=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
  37. echo "Changed files:"
  38. echo "$changed"
  39. # Only these modules directly affect what 'details', 'parse-game-details'
  40. # and 'query-raw' output. Everything else (install, fix, update, check_*,
  41. # data CSVs, game icons, etc.) is irrelevant to this check.
  42. details_core='^(linuxgsm\.sh|lgsm/modules/(info_game|info_messages|command_details|command_dev_parse_game_details|command_dev_query_raw|core_modules)\.sh)$'
  43. if echo "$changed" | grep -qE "${details_core}"; then
  44. echo "Details-relevant core file changed — using full matrix."
  45. echo "mode=full" >> "$GITHUB_OUTPUT"
  46. else
  47. # Extract shortnames from changed config-lgsm paths
  48. shortnames=$(echo "$changed" \
  49. | grep -oE 'lgsm/config-default/config-lgsm/[a-z0-9]+server' \
  50. | sed 's|lgsm/config-default/config-lgsm/||;s|server$||' \
  51. | sort -u)
  52. if [ -z "$shortnames" ]; then
  53. echo "No server configs or core files changed — skipping matrix."
  54. echo "mode=skip" >> "$GITHUB_OUTPUT"
  55. else
  56. echo "Targeted servers: $shortnames"
  57. echo "mode=targeted" >> "$GITHUB_OUTPUT"
  58. printf '%s\n' $shortnames > targeted_shortnames.txt
  59. fi
  60. fi
  61. - name: Generate matrix with generate-matrix.sh
  62. if: github.event_name != 'pull_request' || steps.targeted.outputs.mode != 'skip'
  63. run: |
  64. if [ -f targeted_shortnames.txt ]; then
  65. TARGETED_SHORTNAMES=$(cat targeted_shortnames.txt) .github/scripts/details-check-generate-matrix.sh
  66. else
  67. .github/scripts/details-check-generate-matrix.sh
  68. fi
  69. - name: Set Matrix
  70. id: set-matrix
  71. run: |
  72. if [ ! -f shortnamearray.json ]; then
  73. echo 'matrix={"include":[]}' >> "$GITHUB_OUTPUT"
  74. else
  75. shortnamearray=$(cat shortnamearray.json)
  76. echo "${shortnamearray}"
  77. echo -n "matrix=${shortnamearray}" >> "$GITHUB_OUTPUT"
  78. fi
  79. details-check:
  80. if: github.repository_owner == 'GameServerManagers'
  81. needs: create-matrix
  82. continue-on-error: true
  83. runs-on: ${{ matrix.runner }}
  84. env:
  85. LGSM_REF: ${{ github.event.pull_request.head.sha || github.ref_name }}
  86. strategy:
  87. matrix: ${{ fromJSON(needs.create-matrix.outputs.matrix) }}
  88. steps:
  89. - name: Download linuxgsm.sh
  90. run: wget "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/${LGSM_REF}/linuxgsm.sh"; chmod +x linuxgsm.sh
  91. - name: Cache apt packages
  92. uses: actions/cache@v6
  93. with:
  94. path: /var/cache/apt/archives
  95. key: apt-${{ runner.os }}-libxml2-utils-jq
  96. - name: Install dependencies
  97. run: sudo apt-get install -y --no-install-recommends libxml2-utils jq
  98. - name: Create serverfiles directory
  99. run: mkdir -p serverfiles
  100. - name: Grab server
  101. run: LGSM_GITHUBBRANCH="${LGSM_REF}" ./linuxgsm.sh ${{ matrix.shortname }}server
  102. - name: Enable developer mode
  103. run: LGSM_GITHUBBRANCH="${LGSM_REF}" ./${{ matrix.shortname }}server developer
  104. - name: Generate servercfgname
  105. id: sets-servercfgname
  106. run: |
  107. servercfg=$(sed -n "/^\<servercfgdefault\>/ { s/.*= *\"\?\([^\"']*\)\"\?/\1/p;q }" lgsm/config-lgsm/${{ matrix.shortname }}server/_default.cfg)
  108. echo "servercfgname=$servercfg" >> "$GITHUB_OUTPUT"
  109. - name: Download config
  110. run: |
  111. if [ "${{ steps.sets-servercfgname.outputs.servercfgname }}" == "" ]; then
  112. echo "This game server has no config file."
  113. else
  114. curl -f -o config "https://raw.githubusercontent.com/GameServerManagers/Game-Server-Configs/main/${{ matrix.shortname }}/${{ steps.sets-servercfgname.outputs.servercfgname }}"
  115. fi
  116. - name: Pre-load LinuxGSM
  117. run: LGSM_GITHUBBRANCH="${LGSM_REF}" ./${{ matrix.shortname }}server details
  118. - name: Display config
  119. run: |
  120. if [ "${{ steps.sets-servercfgname.outputs.servercfgname }}" == "" ]; then
  121. echo "This game server has no config file."
  122. else
  123. cat config
  124. fi
  125. - name: Display parameters
  126. run: grep "startparameters" lgsm/config-default/config-lgsm/${{ matrix.shortname }}server/_default.cfg
  127. - name: Details
  128. id: details
  129. run: LGSM_GITHUBBRANCH="${LGSM_REF}" ./${{ matrix.shortname }}server details
  130. - name: Detect details
  131. id: detect-details
  132. run: LGSM_GITHUBBRANCH="${LGSM_REF}" ./${{ matrix.shortname }}server parse-game-details
  133. - name: Query Raw
  134. id: query-raw
  135. run: LGSM_GITHUBBRANCH="${LGSM_REF}" ./${{ matrix.shortname }}server query-raw
  136. - name: Write job summary
  137. if: always()
  138. run: |
  139. status_icon() {
  140. case "$1" in
  141. success) echo "✅" ;;
  142. failure) echo "❌" ;;
  143. skipped) echo "⏭️" ;;
  144. *) echo "⚠️" ;;
  145. esac
  146. }
  147. details_icon=$(status_icon "${{ steps.details.outcome }}")
  148. parse_icon=$(status_icon "${{ steps.detect-details.outcome }}")
  149. query_icon=$(status_icon "${{ steps.query-raw.outcome }}")
  150. {
  151. echo "## ${{ matrix.shortname }}server"
  152. echo "| Step | Result |"
  153. echo "|------|--------|"
  154. echo "| Details | ${details_icon} ${{ steps.details.outcome }} |"
  155. echo "| Parse game details | ${parse_icon} ${{ steps.detect-details.outcome }} |"
  156. echo "| Query raw | ${query_icon} ${{ steps.query-raw.outcome }} |"
  157. } >> "$GITHUB_STEP_SUMMARY"