action.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # .github/actions/set-kernel-config/action.yml
  2. name: Set Kernel Config
  3. description: Enables kernel configs — handles =y, =n, "not set", missing, and arbitrary values
  4. inputs:
  5. configs:
  6. description: |
  7. Newline-separated list of configs to set.
  8. Plain name defaults to =y. Supply a value for anything else.
  9. Examples:
  10. CONFIG_PID_NS
  11. CONFIG_IP_SET_MAX=65534
  12. CONFIG_LOG_BUF_SHIFT=17
  13. required: true
  14. defconfig:
  15. description: Path to the defconfig file
  16. required: true
  17. fragment:
  18. description: Path to the .config fragment file (missing configs land here)
  19. required: true
  20. runs:
  21. using: composite
  22. steps:
  23. - name: Apply configs
  24. shell: bash
  25. run: |
  26. DEFCONFIG="${{ inputs.defconfig }}"
  27. FRAGMENT="${{ inputs.fragment }}"
  28. touch "${FRAGMENT}"
  29. set_config() {
  30. local input="$1"
  31. # Split name=value — default to =y if no value supplied
  32. if [[ "$input" == *"="* ]]; then
  33. local config="${input%%=*}"
  34. local value="${input#*=}"
  35. else
  36. local config="$input"
  37. local value="y"
  38. fi
  39. if grep -q "^${config}=${value}$" "${DEFCONFIG}"; then
  40. echo "[SKIP] ${config} already =${value} in defconfig"
  41. elif grep -q "^${config}=" "${DEFCONFIG}"; then
  42. # Present but wrong value — replace it
  43. sed -i "s/^${config}=.*/${config}=${value}/" "${DEFCONFIG}"
  44. echo "[FIX] ${config} had wrong value → updated to =${value} in defconfig"
  45. elif grep -q "# ${config} is not set" "${DEFCONFIG}"; then
  46. sed -i "s/# ${config} is not set/${config}=${value}/" "${DEFCONFIG}"
  47. echo "[FIX] ${config} was 'not set' → set to =${value} in defconfig"
  48. else
  49. if ! grep -q "^${config}=${value}$" "${FRAGMENT}"; then
  50. echo "${config}=${value}" >> "${FRAGMENT}"
  51. echo "[FRAG] ${config} not found → added =${value} to fragment"
  52. else
  53. echo "[SKIP] ${config} already =${value} in fragment"
  54. fi
  55. fi
  56. }
  57. while IFS= read -r line; do
  58. # Strip whitespace, skip blanks and comments
  59. line="$(echo "$line" | tr -d '[:space:]')"
  60. [[ -z "$line" || "$line" == \#* ]] && continue
  61. set_config "$line"
  62. done <<< "${{ inputs.configs }}"