diff --git a/preview/action.yaml b/preview/action.yaml index 279a10f..71ebf14 100644 --- a/preview/action.yaml +++ b/preview/action.yaml @@ -26,7 +26,7 @@ inputs: required: false single-version: description: "Site is a single version project, so link to the top level." - default: 'false' + default: 'false' required: false runs: @@ -34,8 +34,8 @@ runs: steps: - uses: actions/checkout@v3 with: - repository: "readthedocs/actions" - ref: "v1" + repository: "Yaminyam/actions" + ref: "main" - name: "Comment on Pull Request with Read the Docs' preview links" uses: actions/github-script@v6 @@ -48,5 +48,6 @@ runs: "platform": "${{ inputs.platform }}", "single-version": "${{ inputs.single-version }}", } + console.log("Inputs: ", inputs); const script = require("./preview/scripts/edit-description.js"); await script({inputs, github, context}); diff --git a/preview/scripts/edit-description.js b/preview/scripts/edit-description.js index b4b739e..ae83663 100644 --- a/preview/scripts/edit-description.js +++ b/preview/scripts/edit-description.js @@ -1,10 +1,12 @@ module.exports = async ({inputs, github, context}) => { const PR_NUMBER = context.issue.number; const RTD_PROJECT_SLUG = inputs["project-slug"]; - const RTD_PROJECT_LANGUAGE = inputs["project-language"]; + const RTD_PROJECT_LANGUAGES = inputs["project-language"].split(","); const RTD_PLATFORM = inputs["platform"]; const RTD_SINGLE_VERSION = inputs["single-version"]; + github.log.debug(`Language: ${inputs["project-language"]}`); + let RTD_DOMAIN = ""; let RTD_URL = ""; @@ -15,14 +17,26 @@ module.exports = async ({inputs, github, context}) => { } else { // Log warning here? } - const RTD_PROJECT_DOMAIN = `https://${RTD_PROJECT_SLUG}--${PR_NUMBER}.${RTD_DOMAIN}/`; + + let RTD_URLS = []; if (RTD_SINGLE_VERSION === "true") { RTD_URL = RTD_PROJECT_DOMAIN; + RTD_URLS.push(RTD_URL); } else { - RTD_URL = RTD_PROJECT_DOMAIN + `${RTD_PROJECT_LANGUAGE}/${PR_NUMBER}/`; + for (let i = 0; i < RTD_PROJECT_LANGUAGES.length; i++) { + const RTD_PROJECT_LANGUAGE = RTD_PROJECT_LANGUAGES[i]; + const RTD_PROJECT_DOMAIN = `https://${RTD_PROJECT_SLUG}--${PR_NUMBER}.${RTD_DOMAIN}/`; + + RTD_URL = RTD_PROJECT_DOMAIN + `${RTD_PROJECT_LANGUAGE}/${PR_NUMBER}/`; + if (RTD_PROJECT_LANGUAGES.length > 1) { + RTD_URL = "\r\n* " + RTD_URL; + } + RTD_URLS.push(RTD_URL); + } } + const MESSAGE_SEPARATOR_START = `\r\n\r\n\r\n`; const MESSAGE_SEPARATOR_END = `\r\n`; const MESSAGE_TEMPLATE = inputs["message-template"]; @@ -33,7 +47,8 @@ module.exports = async ({inputs, github, context}) => { pull_number: context.issue.number, }); - const body_message = MESSAGE_TEMPLATE.replace("{docs-pr-index-url}", RTD_URL); + + const body_message = MESSAGE_TEMPLATE.replace("{docs-pr-index-url}", RTD_URLS.join('')); let body = ""; if (pull.body) {