index-monitor.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. name: '[Index] Monitor remote index.yaml'
  2. on:
  3. schedule:
  4. # Every 10 minutes
  5. - cron: '*/10 * * * *'
  6. # Remove all permissions by default
  7. permissions: {}
  8. jobs:
  9. integrity-check:
  10. name: Compare the index.yaml checksums remote and locally
  11. runs-on: ubuntu-latest
  12. permissions:
  13. contents: read
  14. outputs:
  15. result: ${{ steps.integrity-check.outputs.result }}
  16. if: ${{ github.repository_owner == 'bitnami' }}
  17. steps:
  18. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
  19. with:
  20. ref: 'index'
  21. - name: Check index integrity
  22. id: integrity-check
  23. run: |
  24. status="fail"
  25. attempts=0
  26. # We want to check for consistent failures
  27. # To do so, we will look for 3 consecutive failures with a 30 seconds wait
  28. # A single success is enough to pass
  29. while [[ "${status}" != "ok" && $attempts -lt 3 ]]; do
  30. # Check the index.yaml integrity
  31. REMOTE_MD5=($(curl -Ls https://charts.bitnami.com/bitnami/index.yaml | md5sum))
  32. REPOSITORY_MD5=($(md5sum bitnami/index.yaml))
  33. # Compare the index.yaml checksums remote and locally
  34. if [[ "${REPOSITORY_MD5[0]}" == "${REMOTE_MD5[0]}" ]]; then
  35. status='ok'
  36. else
  37. attempts=$((attempts+1))
  38. echo "Integrity check failed. Remote checksum '${REMOTE_MD5[0]}' does not match expected '${REPOSITORY_MD5[0]}'";
  39. # Refresh the 'index' branch in case it was updated
  40. git fetch origin index
  41. git reset --hard origin/index
  42. # Wait 30 seconds
  43. sleep 30
  44. fi
  45. done
  46. echo "result=${status}" >> $GITHUB_OUTPUT
  47. - name: Show messages
  48. uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
  49. with:
  50. script: |
  51. if ("${{ steps.integrity-check.outputs.result }}" != "ok" ) {
  52. core.setFailed("Integrity check failed");
  53. } else {
  54. core.info("Integrity check succeeded")
  55. }
  56. validation-check:
  57. name: Validate the helm repository can be added and updated
  58. runs-on: ubuntu-latest
  59. permissions:
  60. contents: read
  61. outputs:
  62. result: ${{ steps.validation-check.outputs.result }}
  63. if: ${{ github.repository_owner == 'bitnami' }}
  64. steps:
  65. - name: Install helm
  66. run: |
  67. HELM_TARBALL="helm-v3.8.1-linux-amd64.tar.gz"
  68. curl -SsLfO "https://get.helm.sh/${HELM_TARBALL}" && sudo tar xf "$HELM_TARBALL" --strip-components 1 -C /usr/local/bin
  69. - name: Validate helm repository
  70. id: validation-check
  71. run: |
  72. repo="https://charts.bitnami.com/bitnami"
  73. status="fail"
  74. attempts=0
  75. # We want to check for consistent failures
  76. # To do so, we will look for 3 consecutive failures with a 30 seconds wait
  77. # A single success is enough to pass
  78. while [[ "${status}" != "ok" && $attempts -lt 3 ]]; do
  79. # Validates the helm repository can be added and updated
  80. if helm repo add bitnami "${repo}" && helm repo update bitnami; then
  81. status="ok"
  82. else
  83. attempts=$((attempts+1))
  84. echo "Failed to pull charts from helm repository '${repo}'"
  85. # If present, remove repository to allow retries
  86. if helm repo list | grep -q bitnami; then
  87. helm repo remove bitnami
  88. fi
  89. # Wait 30 seconds
  90. sleep 30
  91. fi
  92. done
  93. echo "result=${status}" >> $GITHUB_OUTPUT
  94. - name: Show messages
  95. uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
  96. with:
  97. script: |
  98. if ("${{ steps.validation-check.outputs.result }}" != "ok" ) {
  99. core.setFailed("Validation check failed");
  100. } else {
  101. core.info("Validation check succeeded")
  102. }
  103. upload:
  104. name: Re-upload index.yaml
  105. needs: [validation-check, integrity-check]
  106. if: ${{ always() && github.repository_owner == 'bitnami' && (needs.validation-check.outputs.result != 'ok' || needs.integrity-check.outputs.result != 'ok') }}
  107. uses: bitnami/charts/.github/workflows/sync-chart-cloudflare-index.yml@index
  108. secrets: inherit
  109. permissions:
  110. contents: read
  111. notify:
  112. name: Send notification
  113. needs: [validation-check, integrity-check]
  114. if: ${{ always() && github.repository_owner == 'bitnami' && (needs.validation-check.outputs.result != 'ok' || needs.integrity-check.outputs.result != 'ok') }}
  115. uses: bitnami/support/.github/workflows/gchat-notification.yml@main
  116. with:
  117. workflow: ${{ github.workflow }}
  118. job-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
  119. secrets:
  120. webhook-url: ${{ secrets.GCHAT_WEBHOOK_URL }}