details-check.yml 6.5 KB

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