commit-status.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. name: Commit Status Report
  2. on:
  3. workflow_dispatch:
  4. jobs:
  5. report:
  6. runs-on: ubuntu-latest
  7. permissions:
  8. contents: read
  9. steps:
  10. - name: Checkout repository
  11. uses: actions/checkout@v5
  12. - name: Build commit summary
  13. shell: bash
  14. env:
  15. COMMITS_JSON: .github/config/commits.json
  16. run: |
  17. set -euo pipefail
  18. summary_file="$GITHUB_STEP_SUMMARY"
  19. sanitize_cell() {
  20. local value="$1"
  21. value="${value//$'\r'/ }"
  22. value="${value//$'\n'/ }"
  23. value="${value//|/\\|}"
  24. printf '%s' "$value"
  25. }
  26. gitlab_commit_message() {
  27. local sha="$1"
  28. curl -fsSL "https://gitlab.com/api/v4/projects/simonpunk%2Fsusfs4ksu/repository/commits/${sha}" | jq -r '.message | split("\n")[0]'
  29. }
  30. gitlab_latest_commit() {
  31. local branch="$1"
  32. curl -fsSL "https://gitlab.com/api/v4/projects/simonpunk%2Fsusfs4ksu/repository/commits?ref_name=${branch}&per_page=1" | jq -r '.[0].id'
  33. }
  34. gitlab_latest_message() {
  35. local branch="$1"
  36. curl -fsSL "https://gitlab.com/api/v4/projects/simonpunk%2Fsusfs4ksu/repository/commits?ref_name=${branch}&per_page=1" | jq -r '.[0].message | split("\n")[0]'
  37. }
  38. github_commit_message() {
  39. local sha="$1"
  40. curl -fsSL "https://api.github.com/repos/KernelSU-Next/KernelSU-Next/commits/${sha}" | jq -r '.commit.message | split("\n")[0]'
  41. }
  42. github_latest_commit() {
  43. curl -fsSL "https://api.github.com/repos/KernelSU-Next/KernelSU-Next/commits/dev" | jq -r '.sha'
  44. }
  45. github_latest_message() {
  46. curl -fsSL "https://api.github.com/repos/KernelSU-Next/KernelSU-Next/commits/dev" | jq -r '.commit.message | split("\n")[0]'
  47. }
  48. {
  49. echo "# Commit Status Report"
  50. echo ""
  51. echo "This report shows the pinned commit from this repository and the latest upstream commit for each supported SUSFS branch plus KernelSU-Next."
  52. echo ""
  53. } >> "$summary_file"
  54. {
  55. echo "## SUSFS"
  56. echo ""
  57. echo "| Branch | Current Commit | Current Message | Latest Commit | Latest Message |"
  58. echo "| --- | --- | --- | --- | --- |"
  59. } >> "$summary_file"
  60. while IFS= read -r branch; do
  61. current_commit="$(jq -r --arg key "$branch" '.susfs[$key]' "$COMMITS_JSON")"
  62. latest_commit="$(gitlab_latest_commit "$branch")"
  63. current_message="$(gitlab_commit_message "$current_commit")"
  64. latest_message="$(gitlab_latest_message "$branch")"
  65. current_message="$(sanitize_cell "$current_message")"
  66. latest_message="$(sanitize_cell "$latest_message")"
  67. printf '| %s | %s | %s | %s | %s |\n' "$branch" "$current_commit" "$current_message" "$latest_commit" "$latest_message" >> "$summary_file"
  68. done < <(jq -r '.susfs | keys[]' "$COMMITS_JSON" | sort)
  69. {
  70. echo ""
  71. echo "## KernelSU-Next"
  72. echo ""
  73. echo "| Branch | Current Commit | Current Message | Latest Commit | Latest Message |"
  74. echo "| --- | --- | --- | --- | --- |"
  75. } >> "$summary_file"
  76. current_kernelsu_commit="$(jq -r '.kernelsu.dev' "$COMMITS_JSON")"
  77. latest_kernelsu_commit="$(github_latest_commit)"
  78. current_kernelsu_message="$(github_commit_message "$current_kernelsu_commit")"
  79. latest_kernelsu_message="$(github_latest_message)"
  80. current_kernelsu_message="$(sanitize_cell "$current_kernelsu_message")"
  81. latest_kernelsu_message="$(sanitize_cell "$latest_kernelsu_message")"
  82. printf '| %s | %s | %s | %s | %s |\n' "dev" "$current_kernelsu_commit" "$current_kernelsu_message" "$latest_kernelsu_commit" "$latest_kernelsu_message" >> "$summary_file"