зеркало из https://github.com/electron/sheriff.git
feat: support custom repo properties (#53)
* feat: support custom repo properties * nvm logging good * node 18
This commit is contained in:
Родитель
4e490c1ca5
Коммит
92b1639ae5
|
@ -19,7 +19,7 @@ jobs:
|
|||
- name: Setup Node.js
|
||||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # tag: v3.6.0
|
||||
with:
|
||||
node-version: 16.x
|
||||
node-version: 18.x
|
||||
- name: Lint
|
||||
run: |
|
||||
yarn
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"dependencies": {
|
||||
"@electron/github-app-auth": "^2.0.0",
|
||||
"@octokit/graphql": "^5.0.6",
|
||||
"@octokit/rest": "^19.0.11",
|
||||
"@octokit/rest": "^20.0.2",
|
||||
"@octokit/webhooks": "^10.9.0",
|
||||
"@slack/web-api": "^6.8.0",
|
||||
"@slack/webhook": "^6.1.0",
|
||||
|
|
|
@ -118,6 +118,7 @@ const validateConfigFast = async (config: PermissionsConfig) => {
|
|||
has_wiki: Joi.boolean(),
|
||||
}).optional(),
|
||||
visibility: Joi.string().only('public', 'private').optional(),
|
||||
properties: Joi.object().pattern(Joi.string(), Joi.string()).optional(),
|
||||
})
|
||||
.required(),
|
||||
});
|
||||
|
@ -1026,6 +1027,40 @@ async function checkRepository(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (repo.properties) {
|
||||
const octokit = await getOctokit(config.organization);
|
||||
const props = await octokit.repos.getCustomPropertiesValues({
|
||||
owner: config.organization,
|
||||
repo: repo.name,
|
||||
});
|
||||
|
||||
const sortProps = (a: typeof mappedProperties[0], b: typeof mappedProperties[0]) =>
|
||||
a.property_name.localeCompare(b.property_name);
|
||||
const mappedProperties = Object.entries(repo.properties)
|
||||
.map(([key, value]) => ({
|
||||
property_name: key,
|
||||
value: value as string | null,
|
||||
}))
|
||||
.sort(sortProps);
|
||||
props.data.sort(sortProps);
|
||||
if (JSON.stringify(props.data) !== JSON.stringify(mappedProperties)) {
|
||||
console.info(
|
||||
chalk.green('Updating Repository Properties'),
|
||||
chalk.cyan(repo.name),
|
||||
'setting to',
|
||||
chalk.cyan(JSON.stringify(repo.properties, null, 2)),
|
||||
);
|
||||
|
||||
if (!IS_DRY_RUN) {
|
||||
await octokit.orgs.createOrUpdateCustomPropertiesValuesForRepos({
|
||||
org: config.organization,
|
||||
repository_names: [repo.name],
|
||||
properties: mappedProperties,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
|
|
|
@ -12,6 +12,7 @@ export interface RepositoryConfig {
|
|||
external_collaborators?: Record<string, SheriffAccessLevel>;
|
||||
settings?: Partial<RepoSettings>;
|
||||
visibility?: 'public' | 'private';
|
||||
properties?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface RepoSettings {
|
||||
|
|
97
yarn.lock
97
yarn.lock
|
@ -67,6 +67,11 @@
|
|||
dependencies:
|
||||
"@octokit/types" "^9.0.0"
|
||||
|
||||
"@octokit/auth-token@^4.0.0":
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-4.0.0.tgz#40d203ea827b9f17f42a29c6afb93b7745ef80c7"
|
||||
integrity sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==
|
||||
|
||||
"@octokit/core@^4.2.1":
|
||||
version "4.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-4.2.1.tgz#fee6341ad0ce60c29cc455e056cd5b500410a588"
|
||||
|
@ -80,6 +85,19 @@
|
|||
before-after-hook "^2.2.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/core@^5.0.0":
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-5.0.1.tgz#865da2b30d54354cccb6e30861ddfa0e24494780"
|
||||
integrity sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==
|
||||
dependencies:
|
||||
"@octokit/auth-token" "^4.0.0"
|
||||
"@octokit/graphql" "^7.0.0"
|
||||
"@octokit/request" "^8.0.2"
|
||||
"@octokit/request-error" "^5.0.0"
|
||||
"@octokit/types" "^12.0.0"
|
||||
before-after-hook "^2.2.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/endpoint@^7.0.0":
|
||||
version "7.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-7.0.5.tgz#2bb2a911c12c50f10014183f5d596ce30ac67dd1"
|
||||
|
@ -89,6 +107,15 @@
|
|||
is-plain-object "^5.0.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/endpoint@^9.0.0":
|
||||
version "9.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-9.0.1.tgz#c3f69d27accddcb04a3199fcef541804288149d2"
|
||||
integrity sha512-hRlOKAovtINHQPYHZlfyFwaM8OyetxeoC81lAkBy34uLb8exrZB50SQdeW3EROqiY9G9yxQTpp5OHTV54QD+vA==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.0.0"
|
||||
is-plain-object "^5.0.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/graphql@^5.0.0", "@octokit/graphql@^5.0.6":
|
||||
version "5.0.6"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-5.0.6.tgz#9eac411ac4353ccc5d3fca7d76736e6888c5d248"
|
||||
|
@ -98,6 +125,15 @@
|
|||
"@octokit/types" "^9.0.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/graphql@^7.0.0":
|
||||
version "7.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-7.0.2.tgz#3df14b9968192f9060d94ed9e3aa9780a76e7f99"
|
||||
integrity sha512-OJ2iGMtj5Tg3s6RaXH22cJcxXRi7Y3EBqbHTBRq+PQAqfaS8f/236fUrWhfSn8P4jovyzqucxme7/vWSSZBX2Q==
|
||||
dependencies:
|
||||
"@octokit/request" "^8.0.1"
|
||||
"@octokit/types" "^12.0.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/oauth-authorization-url@^5.0.0":
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/oauth-authorization-url/-/oauth-authorization-url-5.0.0.tgz#029626ce87f3b31addb98cd0d2355c2381a1c5a1"
|
||||
|
@ -119,6 +155,11 @@
|
|||
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-17.2.0.tgz#f1800b5f9652b8e1b85cc6dfb1e0dc888810bdb5"
|
||||
integrity sha512-MazrFNx4plbLsGl+LFesMo96eIXkFgEtaKbnNpdh4aQ0VM10aoylFsTYP1AEjkeoRNZiiPe3T6Gl2Hr8dJWdlQ==
|
||||
|
||||
"@octokit/openapi-types@^19.0.1":
|
||||
version "19.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-19.0.1.tgz#b83bd8ef1a6e1a2d88072c87747fa130348ef8fe"
|
||||
integrity sha512-zC+73r2HIoRb9rWW5S3Y759hrpadlD5pNnya/QfZv0JZE7mvMu+FUa7nxHqTadi2hZc4BPZjJ8veDTuJnh8+8g==
|
||||
|
||||
"@octokit/plugin-paginate-rest@^6.1.2":
|
||||
version "6.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-6.1.2.tgz#f86456a7a1fe9e58fec6385a85cf1b34072341f8"
|
||||
|
@ -127,11 +168,30 @@
|
|||
"@octokit/tsconfig" "^1.0.2"
|
||||
"@octokit/types" "^9.2.3"
|
||||
|
||||
"@octokit/plugin-paginate-rest@^9.0.0":
|
||||
version "9.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.1.0.tgz#215040a2e9d93497b46d7f88c8566f958c97e1c4"
|
||||
integrity sha512-FK1WMa5261SaMX/33S1EOEzalnu9+YoKfrxzRVimciachMFSWH9kQ9SOKdxxxuZXX+KxCLw1knQkneSLYmgdbg==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.1.0"
|
||||
|
||||
"@octokit/plugin-request-log@^1.0.4":
|
||||
version "1.0.4"
|
||||
resolved "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz"
|
||||
integrity sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==
|
||||
|
||||
"@octokit/plugin-request-log@^4.0.0":
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-4.0.0.tgz#260fa6970aa97bbcbd91f99f3cd812e2b285c9f1"
|
||||
integrity sha512-2uJI1COtYCq8Z4yNSnM231TgH50bRkheQ9+aH8TnZanB6QilOnx8RMD2qsnamSOXtDj0ilxvevf5fGsBhBBzKA==
|
||||
|
||||
"@octokit/plugin-rest-endpoint-methods@^10.0.0":
|
||||
version "10.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.1.0.tgz#0633ba7da42b9333444dd0880ab383a0860662fb"
|
||||
integrity sha512-SnVot2WFI61LYkTeSCkKNfvfqw7FdgtqvaC8nMUwYiHA8UTKoGDjL+R5pCaCEvoLu3O55pUOtNaTIyo7ngJySQ==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.1.0"
|
||||
|
||||
"@octokit/plugin-rest-endpoint-methods@^7.1.2":
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-7.1.2.tgz#b77a8844601d3a394a02200cddb077f3ab841f38"
|
||||
|
@ -149,6 +209,15 @@
|
|||
deprecation "^2.0.0"
|
||||
once "^1.4.0"
|
||||
|
||||
"@octokit/request-error@^5.0.0":
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-5.0.1.tgz#277e3ce3b540b41525e07ba24c5ef5e868a72db9"
|
||||
integrity sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.0.0"
|
||||
deprecation "^2.0.0"
|
||||
once "^1.4.0"
|
||||
|
||||
"@octokit/request@^6.0.0", "@octokit/request@^6.2.3":
|
||||
version "6.2.5"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-6.2.5.tgz#7beef1065042998f7455973ef3f818e7b84d6ec2"
|
||||
|
@ -161,6 +230,17 @@
|
|||
node-fetch "^2.6.7"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/request@^8.0.1", "@octokit/request@^8.0.2":
|
||||
version "8.1.4"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-8.1.4.tgz#12dfaebdb2ea375eaabb41d39d45182531ac2857"
|
||||
integrity sha512-M0aaFfpGPEKrg7XoA/gwgRvc9MSXHRO2Ioki1qrPDbl1e9YhjIwVoHE7HIKmv/m3idzldj//xBujcFNqGX6ENA==
|
||||
dependencies:
|
||||
"@octokit/endpoint" "^9.0.0"
|
||||
"@octokit/request-error" "^5.0.0"
|
||||
"@octokit/types" "^12.0.0"
|
||||
is-plain-object "^5.0.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/rest@^19.0.11":
|
||||
version "19.0.11"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-19.0.11.tgz#2ae01634fed4bd1fca5b642767205ed3fd36177c"
|
||||
|
@ -171,11 +251,28 @@
|
|||
"@octokit/plugin-request-log" "^1.0.4"
|
||||
"@octokit/plugin-rest-endpoint-methods" "^7.1.2"
|
||||
|
||||
"@octokit/rest@^20.0.2":
|
||||
version "20.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-20.0.2.tgz#5cc8871ba01b14604439049e5f06c74b45c99594"
|
||||
integrity sha512-Ux8NDgEraQ/DMAU1PlAohyfBBXDwhnX2j33Z1nJNziqAfHi70PuxkFYIcIt8aIAxtRE7KVuKp8lSR8pA0J5iOQ==
|
||||
dependencies:
|
||||
"@octokit/core" "^5.0.0"
|
||||
"@octokit/plugin-paginate-rest" "^9.0.0"
|
||||
"@octokit/plugin-request-log" "^4.0.0"
|
||||
"@octokit/plugin-rest-endpoint-methods" "^10.0.0"
|
||||
|
||||
"@octokit/tsconfig@^1.0.2":
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/tsconfig/-/tsconfig-1.0.2.tgz#59b024d6f3c0ed82f00d08ead5b3750469125af7"
|
||||
integrity sha512-I0vDR0rdtP8p2lGMzvsJzbhdOWy405HcGovrspJ8RRibHnyRgggUSNO5AIox5LmqiwmatHKYsvj6VGFHkqS7lA==
|
||||
|
||||
"@octokit/types@^12.0.0", "@octokit/types@^12.1.0":
|
||||
version "12.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-12.1.0.tgz#e31f6d524efb9d49206c5b28ab18fd6688f6a12a"
|
||||
integrity sha512-JmjQr5ZbOnpnOLX5drI2O2I1N9suOYZAgINHXTlVVg4lRtUifMv2JssT+RhmNxQwXH153Pc8HaCMdTRkqI1oVQ==
|
||||
dependencies:
|
||||
"@octokit/openapi-types" "^19.0.1"
|
||||
|
||||
"@octokit/types@^9.0.0", "@octokit/types@^9.2.3":
|
||||
version "9.2.3"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-9.2.3.tgz#d0af522f394d74b585cefb7efd6197ca44d183a9"
|
||||
|
|
Загрузка…
Ссылка в новой задаче