diff --git a/.github/actions/next-stats-action/src/index.js b/.github/actions/next-stats-action/src/index.js index 2bacd52b3501d..d7332d5edc893 100644 --- a/.github/actions/next-stats-action/src/index.js +++ b/.github/actions/next-stats-action/src/index.js @@ -1,3 +1,5 @@ +const path = require('path') +const fs = require('fs-extra') const exec = require('./util/exec') const logger = require('./util/logger') const runConfigs = require('./run') @@ -25,6 +27,13 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) { ;(async () => { try { + if (await fs.pathExists(path.join(process.cwd(), 'SKIP_NEXT_STATS.txt'))) { + console.log( + 'SKIP_NEXT_STATS.txt file present, exiting stats generation..' + ) + process.exit(0) + } + const { stdout: gitName } = await exec( 'git config user.name && git config user.email' ) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 3220cb97664f9..02cacac16397d 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -184,3 +184,14 @@ jobs: key: ${{ github.sha }} - run: ./publish-release.sh + + prStats: + name: Release Stats + runs-on: ubuntu-latest + needs: [publishRelease] + steps: + - uses: actions/checkout@v2 + - run: ./release-stats.sh + - uses: ./.github/actions/next-stats-action + env: + PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }} diff --git a/.github/workflows/release_stats.yml b/.github/workflows/release_stats.yml deleted file mode 100644 index c734488bdc264..0000000000000 --- a/.github/workflows/release_stats.yml +++ /dev/null @@ -1,13 +0,0 @@ -on: release - -name: Generate Release Stats - -jobs: - prStats: - name: Release Stats - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: ./.github/actions/next-stats-action - env: - PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }} diff --git a/release-stats.sh b/release-stats.sh new file mode 100755 index 0000000000000..406d1620f084e --- /dev/null +++ b/release-stats.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +git describe --exact-match + +if [[ ! $? -eq 0 ]];then + echo "Nothing to publish, exiting.." + touch SKIP_NEXT_STATS.txt + exit 0; +fi + +if [[ -z "$NPM_TOKEN" ]];then + echo "No NPM_TOKEN, exiting.." + exit 0; +fi + +echo "Publish occurred, running release stats..." +echo "Waiting 30 seconds to allow publish to finalize" +sleep 30