Skip to content
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

updated repo to use team github app #41

Merged
merged 3 commits into from
Aug 8, 2023
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
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/review-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to use its own (review bot) app? i am afraid how we gonna find out where the team app's id/key being used outside of list-team-members ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could make sense, but because it is being used for exactly the same requirements than list-team-members I thought that we could recycle that app.

For the new org we will need to create a new app anyways.

Copy link
Contributor

Choose a reason for hiding this comment

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

then if this app dies or something else changes, would be useful to have the list of things app needs to access read/write. Just to recover quickly and for sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll be adding it to the README eventually.

It just need read: org permissions. Nothing else.

You can find a comment telling that here

1 change: 1 addition & 0 deletions src/github/pullRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
5 changes: 3 additions & 2 deletions src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down