From a5520a606b0f7ca15ea6e8fb4b0a1c45242b8b19 Mon Sep 17 00:00:00 2001 From: Thang Bui Quang <89576896+thangbuiq@users.noreply.github.com> Date: Fri, 16 Feb 2024 08:34:35 +0000 Subject: [PATCH] feat: comment a table on PR --- .github/workflows/pages.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index fe636b6..ab5abab 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -31,19 +31,6 @@ jobs: yarn install --frozen-lockfile echo "install_after_time=$(date +%s)" >> $GITHUB_ENV - - name: Comment Install Time on Pull Request - if: github.event_name == 'pull_request' - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.TOKEN_GITHUB }} - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: '✅ Dependencies installed successfully with total time: ' + (process.env.install_after_time - process.env.install_before_time) + ' seconds' - }); - - name: Build Website run: | echo "before_time=$(date +%s)" >> $GITHUB_ENV @@ -71,11 +58,20 @@ jobs: with: github-token: ${{ secrets.TOKEN_GITHUB }} script: | + const installTime = process.env.install_after_time - process.env.install_before_time; + const buildTime = process.env.after_time - process.env.before_time; + const table = ` + | Step | Time (seconds) | + |----------------------|----------------| + | Install Dependencies | ${installTime} | + | Build Website | ${buildTime} | + `; + const commentBody = `✅ Test server functionality passed with the following times for each step:\n\n${table}`; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: '✅ Test server functionality passed with total build time: ' + (process.env.after_time - process.env.before_time) + ' seconds' + body: commentBody }); deploy-docusaurus: