@@ -13449,48 +13449,7 @@ function wrappy (fn, cb) {
1344913449
1345013450/***/ }),
1345113451
13452- /***/ 4581:
13453- /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
13454-
13455- "use strict";
13456-
13457- var __importDefault = (this && this.__importDefault) || function (mod) {
13458- return (mod && mod.__esModule) ? mod : { "default": mod };
13459- };
13460- Object.defineProperty(exports, "__esModule", ({ value: true }));
13461- __nccwpck_require__(4227);
13462- const core_1 = __nccwpck_require__(2186);
13463- const github_1 = __nccwpck_require__(5438);
13464- const api_1 = __importDefault(__nccwpck_require__(3542));
13465- const hasProtectionRuleFilter = (value, hasProtection) => {
13466- if (typeof hasProtection === 'undefined')
13467- return true;
13468- return hasProtection === 'true' ? !!value.length : !value.length;
13469- };
13470- (async () => {
13471- const excludeEnvsInput = (0, core_1.getInput)('exclude-envs', { required: false });
13472- const excludeEnvs = (excludeEnvsInput ? JSON.stringify(excludeEnvsInput) : []);
13473- const hasProtectionRule = (0, core_1.getInput)('has-protection-rule', {
13474- required: false,
13475- }) || undefined;
13476- const repoToken = (0, core_1.getInput)('repo-token', { required: true });
13477- const { repo: { owner, repo }, } = github_1.context;
13478- const fetchEnvs = await api_1.default.get(`/repos/${owner}/${repo}/environments`, {
13479- headers: {
13480- Authorization: `Bearer ${repoToken}`,
13481- },
13482- });
13483- const envList = fetchEnvs.environments
13484- .filter(({ name, protection_rules }) => !excludeEnvs.includes(name) &&
13485- hasProtectionRuleFilter(protection_rules, hasProtectionRule))
13486- .map((it) => it.name);
13487- return (0, core_1.setOutput)('environments', envList);
13488- })();
13489-
13490-
13491- /***/ }),
13492-
13493- /***/ 3542:
13452+ /***/ 9935:
1349413453/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
1349513454
1349613455"use strict";
@@ -13499,14 +13458,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1349913458 return (mod && mod.__esModule) ? mod : { "default": mod };
1350013459};
1350113460Object.defineProperty(exports, "__esModule", ({ value: true }));
13461+ exports.Github = void 0;
1350213462const axios_1 = __importDefault(__nccwpck_require__(8757));
13503- const axiosConfig = axios_1.default.create({
13504- baseURL: 'https://api.github.com',
13505- });
13506- axiosConfig.interceptors.response.use((config) => config.data, ({ response }) => {
13507- throw new Error(JSON.stringify(response?.data, null, 2));
13508- });
13509- exports["default"] = axiosConfig;
13463+ class Github {
13464+ constructor({ apiToken }) {
13465+ this.githubRequest = Github.createGithubConnection(apiToken);
13466+ }
13467+ async listAllEnvironments({ owner, repo, per_page = 2, page = 1, }) {
13468+ let envs = [];
13469+ const { data } = await this.githubRequest.get(`/repos/${owner}/${repo}/environments`, {
13470+ params: {
13471+ per_page,
13472+ page,
13473+ },
13474+ });
13475+ envs = data.environments;
13476+ if (Math.ceil(data.total_count / per_page) >= page + 1) {
13477+ envs = [
13478+ ...envs,
13479+ ...(await this.listAllEnvironments({
13480+ owner,
13481+ repo,
13482+ per_page,
13483+ page: page + 1,
13484+ })),
13485+ ];
13486+ }
13487+ return envs;
13488+ }
13489+ static createGithubConnection(apiToken) {
13490+ return axios_1.default.create({
13491+ baseURL: 'https://api.github.com',
13492+ headers: {
13493+ Authorization: `Bearer ${apiToken}`,
13494+ },
13495+ });
13496+ }
13497+ }
13498+ exports.Github = Github;
1351013499
1351113500
1351213501/***/ }),
@@ -17954,12 +17943,41 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
1795417943/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
1795517944/******/
1795617945/************************************************************************/
17957- /******/
17958- /******/ // startup
17959- /******/ // Load entry module and return exports
17960- /******/ // This entry module is referenced by other modules so it can't be inlined
17961- /******/ var __webpack_exports__ = __nccwpck_require__(4581);
17962- /******/ module.exports = __webpack_exports__;
17963- /******/
17946+ var __webpack_exports__ = {};
17947+ // This entry need to be wrapped in an IIFE because it need to be in strict mode.
17948+ (() => {
17949+ "use strict";
17950+ var exports = __webpack_exports__;
17951+
17952+ Object.defineProperty(exports, "__esModule", ({ value: true }));
17953+ __nccwpck_require__(4227);
17954+ const core_1 = __nccwpck_require__(2186);
17955+ const github_1 = __nccwpck_require__(5438);
17956+ const github_2 = __nccwpck_require__(9935);
17957+ const hasProtectionRuleFilter = (value, hasProtection) => {
17958+ if (typeof hasProtection === 'undefined')
17959+ return true;
17960+ return hasProtection === 'true' ? !!value.length : !value.length;
17961+ };
17962+ (async () => {
17963+ const excludeEnvsInput = (0, core_1.getInput)('exclude-envs', { required: false });
17964+ const excludeEnvs = (excludeEnvsInput ? JSON.stringify(excludeEnvsInput) : []);
17965+ const hasProtectionRule = (0, core_1.getInput)('has-protection-rule', {
17966+ required: false,
17967+ }) || undefined;
17968+ const repoToken = (0, core_1.getInput)('repo-token', { required: true });
17969+ const { repo } = github_1.context;
17970+ const git = new github_2.Github({ apiToken: repoToken });
17971+ const fetchEnvs = await git.listAllEnvironments(repo);
17972+ const envList = fetchEnvs
17973+ .filter(({ name, protection_rules }) => !excludeEnvs.includes(name) &&
17974+ hasProtectionRuleFilter(protection_rules, hasProtectionRule))
17975+ .map((it) => it.name);
17976+ return (0, core_1.setOutput)('environments', envList);
17977+ })();
17978+
17979+ })();
17980+
17981+ module.exports = __webpack_exports__;
1796417982/******/ })()
1796517983;
0 commit comments