diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 89771db..2d17d1a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,8 +23,9 @@ jobs: # as, during development, we change this to use the code from the test branch and # we may forget to set it back to main - name: Validate that action points to main branch + if: github.event_name == 'pull_request' run: | - BRANCH=$(yq '.jobs.review-approvals.steps[0].uses' $FILE_NAME | cut -d "@" -f2) + BRANCH=$(yq '.jobs.review-approvals.steps[1].uses' $FILE_NAME | cut -d "@" -f2) # If the branch is not the main branch if [ "$BRANCH" != "$GITHUB_BASE_REF" ]; then echo "Action points to $BRANCH. It has to point to $GITHUB_BASE_REF instead!" diff --git a/.github/workflows/review-bot.yml b/.github/workflows/review-bot.yml index aece23f..aa6b302 100644 --- a/.github/workflows/review-bot.yml +++ b/.github/workflows/review-bot.yml @@ -18,9 +18,15 @@ jobs: review-approvals: runs-on: ubuntu-latest steps: + - name: Generate token + id: team_token + uses: tibdex/github-app-token@v1 + with: + app_id: ${{ secrets.TEAM_APP_ID }} + private_key: ${{ secrets.TEAM_APP_KEY }} # !This must always point to main. # Change it for the PRs but remember to change it back - uses: paritytech/review-bot@main with: repo-token: ${{ secrets.GITHUB_TOKEN }} - team-token: ${{ secrets.TEST_TEAM_TOKEN }} + team-token: ${{ steps.team_token.outputs.token }} diff --git a/src/github/pullRequest.ts b/src/github/pullRequest.ts index 7a23362..e337a70 100644 --- a/src/github/pullRequest.ts +++ b/src/github/pullRequest.ts @@ -148,6 +148,7 @@ export class PullRequestApi { .addHeading(checkResult.output.title) // We redirect to the check as it can changed if it is triggered again .addLink("Find the result here", check.data.html_url ?? "") + .addBreak() .addRaw(checkResult.output.text) .write(); diff --git a/src/runner.ts b/src/runner.ts index 1d649e6..cba157e 100644 --- a/src/runner.ts +++ b/src/runner.ts @@ -102,9 +102,10 @@ export class ActionRunner { } const { teamsToRequest, usersToRequest } = finalReport; + const validArray = (array: string[] | undefined): boolean => !!array && array.length > 0; const reviewersLog = [ - teamsToRequest ? `Teams: ${JSON.stringify(teamsToRequest)} - ` : "", - usersToRequest ? `Users: ${JSON.stringify(usersToRequest)}` : "", + validArray(teamsToRequest) ? `Teams: ${JSON.stringify(teamsToRequest)}` : "", + validArray(usersToRequest) ? `Users: ${JSON.stringify(usersToRequest)}` : "", ].join(" - "); this.logger.info(`Need to request reviews from ${reviewersLog}`);