action.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. name: Set Kernel Config
  2. description: Patch gki_defconfig directly (add or modify entries)
  3. inputs:
  4. config_list:
  5. required: true
  6. description: "Kernel config lines"
  7. runs:
  8. using: composite
  9. steps:
  10. - name: Patch gki_defconfig
  11. shell: bash
  12. working-directory: ${{ github.workspace }}/kernel/common
  13. run: |
  14. set -euo pipefail
  15. DEFCONFIG="arch/arm64/configs/gki_defconfig"
  16. CONFIG_LIST="${{ inputs.config_list }}"
  17. if [ ! -f "$DEFCONFIG" ]; then
  18. echo "ERROR: gki_defconfig not found"
  19. exit 1
  20. fi
  21. apply_line() {
  22. local line="$1"
  23. line="$(echo "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
  24. # skip empty/comments
  25. [[ -z "$line" || "$line" == \#* ]] && return
  26. local key value
  27. if [[ "$line" == *"="* ]]; then
  28. key="${line%%=*}"
  29. value="${line#*=}"
  30. else
  31. key="$line"
  32. value="y"
  33. fi
  34. echo "Processing: $key=$value"
  35. # if config exists anywhere in file → replace it
  36. if grep -q "^$key=" "$DEFCONFIG"; then
  37. sed -i "s|^$key=.*|$key=$value|g" "$DEFCONFIG"
  38. elif grep -q "^# $key is not set" "$DEFCONFIG"; then
  39. sed -i "s|^# $key is not set|$key=$value|g" "$DEFCONFIG"
  40. else
  41. # not present → append
  42. echo "$key=$value" >> "$DEFCONFIG"
  43. fi
  44. }
  45. while IFS= read -r line || [ -n "$line" ]; do
  46. apply_line "$line"
  47. done <<< "$CONFIG_LIST"