From a08c1b4af37b319af551e446ff8702b1597e3cd0 Mon Sep 17 00:00:00 2001 From: "Austin S. Hemmelgarn" Date: Wed, 14 Jul 2021 12:42:00 -0400 Subject: Properly handle the file list for updating the dashboard. (#11282) Also add slightly nicer logging. --- .github/workflows/dashboard-pr.yml | 4 +--- web/gui/bundle_dashboard.py | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dashboard-pr.yml b/.github/workflows/dashboard-pr.yml index a1e068285b..7461e21b84 100644 --- a/.github/workflows/dashboard-pr.yml +++ b/.github/workflows/dashboard-pr.yml @@ -36,9 +36,7 @@ jobs: env: GH_TOKEN: ${{ secrets.NETDATABOT_GITHUB_TOKEN }} with: - files: | - packaging/dashboard.version - packaging/dashboard.checksums + files: ${{ env.COMMIT_FILES }} # Created by the bundle_dashboard.py script. commit-message: 'Update dashboard to version ${{ github.event.inputs.dashboard_version }}.' ref: refs/heads/dashboard-${{ github.event.inputs.dashboard_version }} - name: Create PR diff --git a/web/gui/bundle_dashboard.py b/web/gui/bundle_dashboard.py index 4cde01af3c..e1815b1e2f 100755 --- a/web/gui/bundle_dashboard.py +++ b/web/gui/bundle_dashboard.py @@ -2,7 +2,9 @@ # # Copyright: © 2021 Netdata Inc. # SPDX-License-Identifier: GPL-3.0-or-later -'''Bundle the dashboard code into the agent repo.''' +'''Bundle the dashboard code into the agent repo. + + This is designed to be run as part of a GHA workflow, but will work fine outside of one.''' import os import shutil @@ -69,12 +71,19 @@ dist_webstaticmedia_DATA = \\ def copy_dashboard(tag): '''Fetch and bundle the dashboard code.''' + print('Preparing target directory') shutil.rmtree(BASEPATH) BASEPATH.mkdir() + print('::group::Fetching dashboard release tarball') subprocess.check_call('curl -L -o dashboard.tar.gz ' + URLTEMPLATE.format(tag), shell=True) + print('::endgroup::') + print('::group::Extracting dashboard release tarball') subprocess.check_call('tar -xvzf dashboard.tar.gz -C ' + str(BASEPATH) + ' --strip-components=1', shell=True) + print('::endgroup::') + print('Copying README.md') BASEPATH.joinpath('README.md').symlink_to('../.dashboard-notice.md') -# BASEPATH.joinpath('..', 'dashboard.tar.gz').unlink() + print('Removing dashboard release tarball') + BASEPATH.joinpath('..', 'dashboard.tar.gz').unlink() def genfilelist(path): @@ -87,6 +96,7 @@ def genfilelist(path): def write_makefile(): '''Write out the makefile for the dashboard code.''' + print('Generating Makefile') MAKEFILEDATA = MAKEFILETEMPLATE.format( genfilelist(BASEPATH), genfilelist(BASEPATH.joinpath('css')), @@ -101,5 +111,15 @@ def write_makefile(): BASEPATH.joinpath('Makefile.am').write_text(MAKEFILEDATA) +def list_changed_files(): + '''Create a list of changed files, and set it in an environment variable.''' + if 'GITHUB_ENV' in os.environ: + print('Generating file list for commit.') + subprocess.check_call('echo "COMMIT_FILES<> $GITHUB_ENV', shell=True) + subprocess.check_call('git status --porcelain=v1 --no-renames --untracked-files=all | rev | cut -d \' \' -f 1 | rev >> $GITHUB_ENV', shell=True) + subprocess.check_call('echo "EOF" >> $GITHUB_ENV', shell=True) + + copy_dashboard(sys.argv[1]) write_makefile() +list_changed_files() -- cgit v1.2.3