archive-full-index.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. name: '[Index] Generate the full bitnami/charts index.yaml'
  2. on:
  3. push:
  4. branches:
  5. - index
  6. jobs:
  7. get:
  8. runs-on: ubuntu-latest
  9. name: Get
  10. steps:
  11. - id: checkout-repo-index
  12. name: Checkout repo
  13. uses: actions/checkout@v4
  14. with:
  15. ref: index
  16. path: index
  17. - id: checkout-repo-full-index
  18. name: Checkout repo
  19. uses: actions/checkout@v4
  20. with:
  21. ref: archive-full-index
  22. path: full-index
  23. - id: get-last-indexes
  24. name: Get indexes
  25. run: |
  26. cp index/bitnami/index.yaml ./last_index.yaml
  27. cp full-index/bitnami/index.yaml ./previous_index.yaml
  28. - id: upload-artifact
  29. name: Upload artifacts
  30. uses: actions/upload-artifact@v4
  31. with:
  32. name: indexes
  33. path: ./*index.yaml
  34. retention-days: 2
  35. if-no-files-found: error
  36. merge:
  37. runs-on: ubuntu-latest
  38. needs: get
  39. name: Merge
  40. steps:
  41. - id: download-artifact
  42. name: Download artifacts
  43. uses: actions/download-artifact@v4
  44. with:
  45. name: indexes
  46. - id: merge
  47. name: Merge
  48. run: yq eval-all '. as $item ireduce ({}; . *+ $item )' previous_index.yaml last_index.yaml > duplicates_index.yaml
  49. - id: remove
  50. name: Remove duplicates
  51. # Removes duplicates per entry using 'digest' as value.
  52. run: yq eval '.entries[] |= unique_by(.digest)' duplicates_index.yaml > index.yaml
  53. - id: upload-artifact
  54. name: Upload artifacts
  55. uses: actions/upload-artifact@v4
  56. with:
  57. name: archive-full-index
  58. path: index.yaml
  59. retention-days: 2
  60. if-no-files-found: error
  61. checks:
  62. runs-on: ubuntu-latest
  63. needs: merge
  64. name: Checks
  65. steps:
  66. - id: download-artifacts
  67. name: Download artifacts
  68. uses: actions/download-artifact@v4
  69. - id: index-lint
  70. name: Lint archive full index
  71. # Lint the resulting archive full index using ignoring identation and lin-length rules.
  72. run: |
  73. cat << EOF > config
  74. extends: relaxed
  75. rules:
  76. indentation:
  77. level: error
  78. line-length: disable
  79. EOF
  80. yamllint -c config archive-full-index/index.yaml
  81. - id: check-no-dups
  82. name: Checks there are not any duplicates
  83. # Try to find duplicate digest attributes which would mean there are duplicates.
  84. run: |
  85. yq eval '.entries[][].digest' archive-full-index/index.yaml | sort | uniq -d | ( ! grep sha256 )
  86. - id: check-missing-releases
  87. name: Checks there are not missing releases
  88. # Available URLs should be fine if everything went well during the merge & deduplication.
  89. run: |
  90. yq eval '.entries[][].urls[]' indexes/last_index.yaml |sort| uniq > last_index_urls
  91. yq eval '.entries[][].urls[]' archive-full-index/index.yaml | sort| uniq > index_urls
  92. missing_urls="$(comm -13 index_urls last_index_urls)"
  93. if [ -n "${missing_urls}" ]; then
  94. echo "Found missing URLs:\n${missing_urls}"
  95. exit 1
  96. fi
  97. echo "No missing releases detected"
  98. update:
  99. runs-on: ubuntu-latest
  100. needs: checks
  101. name: Update
  102. steps:
  103. - id: checkout-repo
  104. name: Checkout repo
  105. uses: actions/checkout@v4
  106. with:
  107. ref: archive-full-index
  108. token: ${{ secrets.BITNAMI_BOT_TOKEN }}
  109. - id: download-artifact-archive-full-index
  110. name: Download artifacts
  111. uses: actions/download-artifact@v4
  112. with:
  113. name: archive-full-index
  114. - id: update-index
  115. name: git-add-push
  116. run: |
  117. git config user.name "Bitnami Containers"
  118. git config user.email "bitnami-bot@vmware.com"
  119. git fetch origin archive-full-index
  120. git reset --hard $(git commit-tree origin/archive-full-index^{tree} -m "Update index.yaml")
  121. # Compare size of files
  122. if [[ $(stat -c%s bitnami/index.yaml) -gt $(stat -c%s index.yaml) ]]; then
  123. echo "New index.yaml file is shorter than the current one"
  124. exit 1
  125. fi
  126. cp index.yaml bitnami/index.yaml
  127. git add bitnami/index.yaml && git commit --signoff --amend --no-edit && git push origin archive-full-index --force-with-lease