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

Open PRs from bot account fix & remove .idea #344

Merged
merged 2 commits into from
Sep 10, 2020
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
19 changes: 0 additions & 19 deletions .idea/$PRODUCT_WORKSPACE_FILE$

This file was deleted.

2 changes: 0 additions & 2 deletions .idea/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/google-api-typings-generator.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/prettier.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

8 changes: 7 additions & 1 deletion bin/auto-update/gitHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export class GitHelpers {
}
};

/**
* @param gapiTypeName - gapi.client.*
*/
pushAndOpenPRIfItDoesNotExistAndIfNotOnlyRevisionChanged = async (
gapiTypeName: string
): Promise<void> => {
Expand All @@ -91,6 +94,7 @@ export class GitHelpers {
dtRepoOwner: owner,
dtRepoName: repo,
thisRepo,
authBot: openPrToken,
} = this.settings;

if (!this.openPRBranches) {
Expand All @@ -116,12 +120,14 @@ export class GitHelpers {

try {
await this.git.octokit.pulls.create({
headers: {
authorization: `token ${openPrToken}`,
},
owner,
repo,
title: `[${gapiTypeName}] automatic update`,
head: `${user}:${gapiTypeName}`,
base: 'master',
// TODO: check for updates in the template (using retrieveCommunityProfileMetrics from black-panther-preview, maybe) but it doesn't seem to be updated often
body: `
- [x] Use a meaningful title for the pull request. Include the name of the package modified.
- [x] Test the change in your own code. (Compile and run.)
Expand Down
10 changes: 8 additions & 2 deletions bin/auto-update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ if (!process.env.GH_AUTH_TOKEN) {
throw new Error('Please, set env var: GH_AUTH_TOKEN');
}

if (!process.env.GH_AUTH_TOKEN_BOT) {
throw new Error('Please, set env var: GH_AUTH_TOKEN_BOT');
}

export interface TypesBranchAndDirSettings {
typesDirName: string; // directory name in DT
typesBranchName: string; // branch name where generated types are in the generator repo
Expand All @@ -24,17 +28,19 @@ export interface Settings extends GitSettings, TypesBranchAndDirSettings {
dtRepoName: string; // DefinitelyTyped repo name only
pullRequestTemplateSHA: string; // SHA of PULL_REQUEST_TEMPLATE.md file from DT
templateUpdateLabel: string; // label for issues regarding PR template update
authBot: string; // GH token for bot account (that will open PRs) with public_repo access
}

const settings: Settings = {
dtForkPath: join(resolve(__dirname, '../..'), 'dt-fork'), // TODO: maybe use require('os').tmpdir() or something like that
typesDirName: 'types',
tempTypesDirName: 'temp-types',
typesBranchName: 'types',
user: 'google-api-typings-generator',
userEmail: 'google-api-typings-generator@mazurok.com',
user: 'Maxim-Mazurok',
userEmail: 'maxim@mazurok.com',
userName: 'Google API Typings Generator',
auth: process.env.GH_AUTH_TOKEN,
authBot: process.env.GH_AUTH_TOKEN_BOT,
dtRepoOwner: 'DefinitelyTyped',
dtRepoName: 'DefinitelyTyped',
thisRepo: 'google-api-typings-generator',
Expand Down
2 changes: 1 addition & 1 deletion bin/get-latest-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {TypesBranchAndDirSettings} from './auto-update';
const pathToTypes = resolve(process.cwd(), process.argv[2]);

const settings: GitSettings & TypesBranchAndDirSettings = {
user: 'google-api-typings-generator',
user: 'Maxim-Mazurok',
auth: process.env.GH_AUTH_TOKEN || '', // token is optional
thisRepo: 'google-api-typings-generator',
typesBranchName: 'types',
Expand Down
1 change: 1 addition & 0 deletions tests/gitHelpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const settings: Settings = {
userEmail: 'userEmail',
userName: 'userName',
auth: 'auth',
authBot: 'authBot',
dtRepoOwner: 'dtRepoOwner',
dtRepoName: 'dtRepoName',
thisRepo: 'thisRepo',
Expand Down