embedded_ui_refresh.yaml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. on:
  2. repository_dispatch:
  3. types: [embedded_ui_refresh]
  4. workflow_dispatch:
  5. inputs:
  6. asset_name:
  7. description: Release asset name
  8. required: true
  9. default: embedded-ui
  10. repository:
  11. description: Source repository
  12. required: true
  13. default: ydb-platform/ydb-embedded-ui
  14. tag_name:
  15. description: Release tag
  16. required: true
  17. name: Embedded UI Refresh
  18. jobs:
  19. main:
  20. runs-on: ubuntu-latest
  21. permissions:
  22. contents: write
  23. pull-requests: write
  24. env:
  25. ASSET_NAME: ${{ github.event.inputs && github.event.inputs.asset_name || github.event.client_payload.asset_name }}
  26. REPOSITORY: ${{ github.event.inputs && github.event.inputs.repository || github.event.client_payload.repository }}
  27. TAG_NAME: ${{ github.event.inputs && github.event.inputs.tag_name || github.event.client_payload.tag_name }}
  28. TEMP_ASSET_DIR: /tmp/asset
  29. steps:
  30. - uses: actions/checkout@v4
  31. - name: Asset Download
  32. env:
  33. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  34. run: gh release download $TAG_NAME --repo $REPOSITORY --pattern $ASSET_NAME.zip --dir $TEMP_ASSET_DIR
  35. - name: Asset Placement
  36. env:
  37. START_POINTER: "# GENERATED MONITORING RESOURCES START"
  38. END_POINTER: "# GENERATED MONITORING RESOURCES END"
  39. TARGET_DIR: ydb/core/viewer/monitoring
  40. YA_MAKE_FILE: ydb/core/viewer/ya.make
  41. run: |
  42. unzip $TEMP_ASSET_DIR/$ASSET_NAME.zip -d $TEMP_ASSET_DIR
  43. rm -rf $TARGET_DIR
  44. mkdir $TARGET_DIR
  45. mv -vf $TEMP_ASSET_DIR/$ASSET_NAME/* $TARGET_DIR
  46. # List of files in the target directory.
  47. NEW_RESOURCES=$(find $TARGET_DIR -type f | sort)
  48. # Current indentation of the start pointer line.
  49. INDENTATION=$(grep -e "$START_POINTER" $YA_MAKE_FILE | perl -lane 's/^(\s+)(.*)+$/$1/e; print')
  50. # Replacing resources list between start and end pointers with saving the current indentation.
  51. perl -0777 -pi -e "s/\s+$START_POINTER.*$END_POINTER/
  52. $INDENTATION$START_POINTER
  53. ${INDENTATION}RESOURCE(
  54. $(echo "$NEW_RESOURCES" | perl -e "while (<>) {chomp; print \"$INDENTATION \$_ \$_\\n\";}" | sed -E 's/\//\\\//g')
  55. $INDENTATION)
  56. $INDENTATION$END_POINTER/s" $YA_MAKE_FILE
  57. - name: Pull Request
  58. uses: peter-evans/create-pull-request@v5
  59. with:
  60. token: ${{ secrets.GITHUB_TOKEN }}
  61. commit-message: "build: refresh Embedded UI (${{ env.TAG_NAME }})"
  62. branch: embedded-ui-refresh-${{ env.TAG_NAME }}
  63. delete-branch: true
  64. title: "build: refresh Embedded UI (${{ env.TAG_NAME }})"
  65. body: |
  66. ### Embedded UI Refresh
  67. Embedded UI
  68. [${{ env.TAG_NAME }}](https://github.com/${{ env.REPOSITORY }}/releases/tag/${{ env.TAG_NAME }})
  69. ([CHANGELOG.md](https://github.com/${{ env.REPOSITORY }}/blob/${{ env.TAG_NAME }}/CHANGELOG.md)).