@@ -24708,7 +24708,6 @@ exports["default"] = _default;
2470824708const fs = __nccwpck_require__(7147);
2470924709const core = __nccwpck_require__(2186);
2471024710const YAML = __nccwpck_require__(4603);
24711- const { createMissingUpdownEntries } = __nccwpck_require__(1764);
2471224711
2471324712const getDashlordConfig = () => {
2471424713  let dashlordConfig;
@@ -24777,9 +24776,17 @@ const getOutputs = () => {
2477724776      .map((s) => s.trim())
2477824777      .filter(Boolean);
2477924778  const toolInput = core.getInput("tool") && core.getInput("tool").trim();
24779+   const tagsInput = 
24780+     core.getInput("tags") &&
24781+     core
24782+       .getInput("tags")
24783+       .split(",")
24784+       .map((s) => s.trim())
24785+       .filter(Boolean);
2478024786
2478124787  core.info(`urlsInput: ${urlsInput}`);
2478224788  core.info(`toolInput: ${toolInput}`);
24789+   core.info(`tagsInput: ${tagsInput}`);
2478324790
2478424791  const isValid = (u) => u.url.match(/^https?:\/\//);
2478524792  let dashlordConfig = getDashlordConfig();
@@ -24802,6 +24809,11 @@ const getOutputs = () => {
2480224809        ? urlsInput.includes(site.url)
2480324810        : true
2480424811    )
24812+     .filter((site) =>
24813+       dashlordConfig.tags && tagsInput && tagsInput.length
24814+         ? site.tags && site.tags.some((t) => tagsInput.includes(t))
24815+         : true
24816+     )
2480524817    .map((site) => ({
2480624818      ...site,
2480724819      tools:
@@ -24826,14 +24838,6 @@ async function run() {
2482624838    core.setOutput("urls", outputs.urls); // legacy ?
2482724839    core.setOutput("sites", JSON.stringify(outputs.sites)); // useful for matrix jobs
2482824840    core.setOutput("config", JSON.stringify(outputs.config)); // full dashloard config
24829- 
24830-     if (
24831-       outputs.config.tools.updownio === true &&
24832-       process.env.UPDOWNIO_API_KEY
24833-     ) {
24834-       console.log("init: create missing updown.io entries");
24835-       await createMissingUpdownEntries(outputs.config);
24836-     }
2483724841  } catch (error) {
2483824842    core.setFailed(error.message);
2483924843  }
@@ -24852,81 +24856,6 @@ module.exports = {
2485224856};
2485324857
2485424858
24855- /***/ }),
24856- 
24857- /***/ 1764:
24858- /***/ ((module) => {
24859- 
24860- // need write API key to create missing urls
24861- 
24862- const apiKey = process.env.UPDOWNIO_API_KEY;
24863- 
24864- const API_HTTP = "https://updown.io/api";
24865- 
24866- /**
24867-  * compare given urls to updown API
24868-  * @function
24869-  * @param {string[]} urls - urls to check
24870-  * @returns {Promise<string[]>} - invalid urls
24871-  */
24872- const getInvalidUrls = async (urls) => {
24873-   const apiUrl = encodeURI(`${API_HTTP}/checks?api-key=${apiKey}`);
24874-   /** @type {{url}[]} */
24875-   const checks = await fetch(apiUrl)
24876-     .then((r) => r.json())
24877-     .then((json) => {
24878-       if (json.error) {
24879-         console.error("e", json.error);
24880-         throw new Error(json.error);
24881-       }
24882-       return json;
24883-     });
24884- 
24885-   /**
24886-    *
24887-    * @param {string} url
24888-    * @returns boolean
24889-    */
24890-   const hasUrl = (url) =>
24891-     !!checks.find(
24892-       (item) =>
24893-         item.url.toLowerCase().replace(/\/$/, "") ===
24894-         url.toLowerCase().replace(/\/$/, "")
24895-     );
24896- 
24897-   return urls.filter((url) => !hasUrl(url));
24898- };
24899- 
24900- const createNewUpDownCheck = async (url) => {
24901-   const apiUrl = encodeURI(`${API_HTTP}/checks?api-key=${apiKey}`);
24902-   const result = await fetch(apiUrl, {
24903-     method: "POST",
24904-     headers: { "Content-Type": "application/json" },
24905-     body: JSON.stringify({ url, published: true }),
24906-   }).then((r) => r.json());
24907-   if (result.error) {
24908-     throw new Error(result.error);
24909-   }
24910-   console.log(JSON.stringify(result, null, 2));
24911- };
24912- 
24913- /**
24914-  *
24915-  * @param {DashLordConfig} dashlordConfig
24916-  */
24917- const createMissingUpdownEntries = async (dashlordConfig) => {
24918-   const urls = dashlordConfig.urls.map((url) => url.url);
24919-   await getInvalidUrls(urls).then((urls) => {
24920-     urls.forEach(async (url) => {
24921-       console.log(`create new updown check for ${url}`);
24922-       await createNewUpDownCheck(url);
24923-     });
24924-   });
24925- };
24926- 
24927- module.exports = { createMissingUpdownEntries };
24928- 
24929- 
2493024859/***/ }),
2493124860
2493224861/***/ 9491:
0 commit comments