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