Skip to content

build: add a CI flow for Embedded UI refresh #1321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/embedded_ui_refresh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
on:
repository_dispatch:
types: [embedded_ui_refresh]
workflow_dispatch:
inputs:
asset_name:
description: Release asset name
required: true
default: embedded-ui
repository:
description: Source repository
required: true
default: ydb-platform/ydb-embedded-ui
tag_name:
description: Release tag
required: true

name: Embedded UI Refresh

jobs:
main:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
ASSET_NAME: ${{ github.event.inputs && github.event.inputs.asset_name || github.event.client_payload.asset_name }}
REPOSITORY: ${{ github.event.inputs && github.event.inputs.repository || github.event.client_payload.repository }}
Comment on lines +27 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will values form client_payload will ever be applied, while inputs.asset_name and inputs.repository have default values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default values are applied when triggering the worflow via GitHub UI (on the screenshot). When you triggers it via the repository_dispatch there is no github.event.inputs field at all.

image

TAG_NAME: ${{ github.event.inputs && github.event.inputs.tag_name || github.event.client_payload.tag_name }}
TEMP_ASSET_DIR: /tmp/asset
steps:
- uses: actions/checkout@v4
- name: Asset Download
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Member

@artemmufazalov artemmufazalov Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between GITHUB_TOKEN and YDB_PLATFORM_BOT_TOKEN_REPO (used in ydb-embedded-ui workflows)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secrets.GITHUB_TOKEN is a default token that is provided by GitHub for any workflow. I found that it used also in docs_preview workflow.

No idea why secrets.GITHUB_TOKEN didn't use in ydb-embedded-ui for opening PRs.

run: gh release download $TAG_NAME --repo $REPOSITORY --pattern $ASSET_NAME.zip --dir $TEMP_ASSET_DIR
- name: Asset Placement
env:
START_POINTER: "# GENERATED MONITORING RESOURCES START"
END_POINTER: "# GENERATED MONITORING RESOURCES END"
TARGET_DIR: ydb/core/viewer/monitoring
YA_MAKE_FILE: ydb/core/viewer/ya.make
run: |
unzip $TEMP_ASSET_DIR/$ASSET_NAME.zip -d $TEMP_ASSET_DIR
rm -rf $TARGET_DIR
mkdir $TARGET_DIR
mv -vf $TEMP_ASSET_DIR/$ASSET_NAME/* $TARGET_DIR

# List of files in the target directory.
NEW_RESOURCES=$(find $TARGET_DIR -type f | sort)

# Current indentation of the start pointer line.
INDENTATION=$(grep -e "$START_POINTER" $YA_MAKE_FILE | perl -lane 's/^(\s+)(.*)+$/$1/e; print')

# Replacing resources list between start and end pointers with saving the current indentation.
perl -0777 -pi -e "s/\s+$START_POINTER.*$END_POINTER/
$INDENTATION$START_POINTER
${INDENTATION}RESOURCE(
$(echo "$NEW_RESOURCES" | perl -e "while (<>) {chomp; print \"$INDENTATION \$_ \$_\\n\";}" | sed -E 's/\//\\\//g')
$INDENTATION)
$INDENTATION$END_POINTER/s" $YA_MAKE_FILE
- name: Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "build: refresh Embedded UI (${{ env.TAG_NAME }})"
branch: embedded-ui-refresh-${{ env.TAG_NAME }}
delete-branch: true
title: "build: refresh Embedded UI (${{ env.TAG_NAME }})"
body: |
### Embedded UI Refresh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't it be considered as a comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that it won't, because it comes after |.


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)).
2 changes: 2 additions & 0 deletions ydb/core/viewer/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ SRCS(
)

IF (NOT EXPORT_CMAKE)
# GENERATED MONITORING RESOURCES START
RESOURCE(
monitoring/index.html monitoring/index.html
monitoring/static/favicon.png monitoring/static/favicon.png
Expand Down Expand Up @@ -162,6 +163,7 @@ IF (NOT EXPORT_CMAKE)
monitoring/static/media/error.ca9e31d5d3dc34da07e11a00f7af0842.svg monitoring/static/media/error.ca9e31d5d3dc34da07e11a00f7af0842.svg
monitoring/static/media/thumbsUp.d4a03fbaa64ce85a0045bf8ba77f8e2b.svg monitoring/static/media/thumbsUp.d4a03fbaa64ce85a0045bf8ba77f8e2b.svg
)
# GENERATED MONITORING RESOURCES END
ENDIF()

RESOURCE(
Expand Down