embedded_ui_refresh.yaml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. ASSET_DIR: monitoring
  38. START_POINTER: "# GENERATED MONITORING RESOURCES START"
  39. END_POINTER: "# GENERATED MONITORING RESOURCES END"
  40. WORKING_DIR: ydb/core/viewer
  41. run: |
  42. set -e
  43. unzip $TEMP_ASSET_DIR/$ASSET_NAME.zip -d $TEMP_ASSET_DIR
  44. cd $WORKING_DIR
  45. rm -rf $ASSET_DIR
  46. mkdir $ASSET_DIR
  47. mv -vf $TEMP_ASSET_DIR/$ASSET_NAME/* $ASSET_DIR
  48. # List of files in the target directory.
  49. NEW_RESOURCES=$(find $ASSET_DIR -type f | sort)
  50. # Current indentation of the start pointer line.
  51. INDENTATION=$(grep -e "$START_POINTER" ya.make | perl -lane 's/^(\s+)(.*)+$/$1/e; print')
  52. # Replacing resources list between start and end pointers with saving the current indentation.
  53. perl -0777 -pi -e "s/\s+$START_POINTER.*$END_POINTER/
  54. $INDENTATION$START_POINTER
  55. ${INDENTATION}RESOURCE(
  56. $(echo "$NEW_RESOURCES" | perl -e "while (<>) {chomp; print \"$INDENTATION \$_ \$_\\n\";}" | sed -E 's/\//\\\//g')
  57. $INDENTATION)
  58. $INDENTATION$END_POINTER/s" ya.make
  59. - name: Pull Request
  60. uses: peter-evans/create-pull-request@v5
  61. with:
  62. token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
  63. commit-message: "build: refresh Embedded UI (${{ env.TAG_NAME }})"
  64. branch: embedded-ui-${{ env.TAG_NAME }}
  65. delete-branch: true
  66. title: "build: refresh Embedded UI (${{ env.TAG_NAME }})"
  67. body: |
  68. ### Embedded UI Refresh
  69. Embedded UI [${{ env.TAG_NAME }}](https://github.com/${{ env.REPOSITORY }}/releases/tag/${{ env.TAG_NAME }}) ([CHANGELOG.md](https://github.com/${{ env.REPOSITORY }}/blob/${{ env.TAG_NAME }}/CHANGELOG.md)).