notify.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. name: Notify Actions
  2. permissions:
  3. contents: read
  4. actions: read
  5. on:
  6. workflow_call:
  7. inputs:
  8. release_type:
  9. required: true
  10. type: string
  11. new_tag:
  12. required: false
  13. type: string
  14. release_result:
  15. required: false
  16. type: string
  17. default: 'success'
  18. secrets:
  19. TELEGRAM_BOT_TOKEN:
  20. required: true
  21. TELEGRAM_CHAT_ID:
  22. required: true
  23. TELEGRAM_TOPIC_ID_GKI:
  24. required: true
  25. TELEGRAM_USER_ID:
  26. required: true
  27. jobs:
  28. notify:
  29. runs-on: ubuntu-latest
  30. steps:
  31. - name: Free Disk Space
  32. if: true
  33. uses: endersonmenezes/free-disk-space@v3
  34. with:
  35. remove_android: true
  36. remove_dotnet: true
  37. remove_haskell: true
  38. remove_tool_cache: true
  39. remove_swap: true
  40. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  41. remove_packages_one_command: true
  42. remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
  43. rm_cmd: "rmz"
  44. rmz_version: "3.1.1"
  45. testing: false
  46. # Download only TheWildJames artifacts for Telegram notification
  47. - name: Download TheWildJames Artifacts
  48. uses: actions/download-artifact@v4
  49. with:
  50. path: ./downloaded-artifacts
  51. pattern: "*-TheWildJames-AnyKernel3"
  52. - name: Prepare Zips
  53. run: |
  54. shopt -s nullglob
  55. # Iterate over directories in downloaded-artifacts
  56. for dir in ./downloaded-artifacts/*-AnyKernel3; do
  57. [ -d "$dir" ] || continue
  58. artifact_name=$(basename "$dir")
  59. echo "Creating ZIP for $artifact_name..."
  60. (cd "$dir" && zip -r -q -9 "$GITHUB_WORKSPACE/${artifact_name}.zip" ./*)
  61. done
  62. - name: Send Telegram Notification (Actions)
  63. if: inputs.release_type == 'Actions' && false
  64. run: |
  65. curl -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
  66. -F chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" \
  67. -F message_thread_id="${{ secrets.TELEGRAM_TOPIC_ID_GKI }}" \
  68. -F text="
  69. 🌽 *New Kernel Actions Build Finished*
  70. 📦 *Repository:* [${{ github.repository }}](https://github.com/${{ github.repository }})
  71. ✏️ *Commit:* [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
  72. [🔗 View Action Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" \
  73. -F parse_mode="Markdown"
  74. - name: Send Telegram Notification (Release)
  75. if: inputs.release_type != 'Actions' && inputs.release_result == 'success' && false
  76. run: |
  77. RELEASE_TYPE_TEXT=""
  78. if [ "${{ inputs.release_type }}" == "Pre-Release" ]; then
  79. RELEASE_TYPE_TEXT="🧪 *Pre-Release*"
  80. else
  81. RELEASE_TYPE_TEXT="🚀 *Release*"
  82. fi
  83. curl -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
  84. -F chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" \
  85. -F message_thread_id="${{ secrets.TELEGRAM_TOPIC_ID_GKI }}" \
  86. -F text="
  87. 🌽 *New Kernel $RELEASE_TYPE_TEXT Uploaded*
  88. 📦 *Repository:* [${{ github.repository }}](https://github.com/${{ github.repository }})
  89. ✏️ *Commit:* [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
  90. [🔗 View GitHub Release](https://github.com/${{ github.repository }}/releases/tag/${{ inputs.new_tag }})" \
  91. -F parse_mode="Markdown"
  92. - name: DM Artifacts
  93. # Always run if the job wasn't cancelled (or follow caller's needs)
  94. if: always()
  95. run: |
  96. shopt -s nullglob
  97. files=("$GITHUB_WORKSPACE"/*.zip)
  98. if [ ${#files[@]} -eq 0 ]; then
  99. echo "No ZIP files found for DM."
  100. exit 0
  101. fi
  102. if [ -z "${{ secrets.TELEGRAM_USER_ID }}" ]; then
  103. echo "Error: TELEGRAM_USER_ID secret is not set."
  104. exit 1
  105. fi
  106. for file in "${files[@]}"; do
  107. echo "Sending $(basename "$file") to Telegram DM..."
  108. # Using || true to prevent failure of one send from failing the whole job
  109. curl -v -F chat_id="${{ secrets.TELEGRAM_USER_ID }}" \
  110. -F document=@"$file" \
  111. -F caption="📦 Build: $(basename "$file")" \
  112. https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument || true
  113. done