diff --git a/action.yml b/action.yml index f5f7a52..7c94ccb 100644 --- a/action.yml +++ b/action.yml @@ -54,6 +54,10 @@ inputs: description: "Set target repository(default: current repository)." required: false default: "" + find_draft_release_count: + description: "How many releases to check when we find a existing draft release.(default: 32)." + required: false + default: "32" outputs: release_id: diff --git a/lib/index.js b/lib/index.js index d3a3e9d..afb5f59 100755 --- a/lib/index.js +++ b/lib/index.js @@ -20689,6 +20689,7 @@ async function run() { var release_id = getInputAsInteger("release_id"); var target_owner = getInputAsString("target_owner"); var target_repo = getInputAsString("target_owner"); + const find_draft_release_count = getInputAsInteger("find_draft_release_count") || 32; if (typeof github_token != "string") { action_core.setFailed("token is invalid"); return; @@ -20713,10 +20714,8 @@ async function run() { // action_github.context.repo.owner = xresloader var release_tag_name = "Release-" + action_github.context.sha.substring(0, 8); var release_name = release_tag_name; - var release_tag_name_has_ref = false; if (custom_tag_name) { release_tag_name = custom_tag_name; - release_tag_name_has_ref = true; } else if ((with_branches && with_branches.length > 0) || with_tags) { // check branches or tags @@ -20725,7 +20724,6 @@ async function run() { const match_tag = action_github.context.ref.match(/refs\/tags\/(.*)/); if (match_tag) { match_filter = true; - release_tag_name_has_ref = true; release_tag_name = match_tag[1]; console.log(`Found tag to push: ${match_tag[1]}.`); } @@ -20841,14 +20839,14 @@ async function run() { } } // We can not get a draft release by getReleaseByTag, so we try to find the draft release with the same name by - if (!(deploy_release && deploy_release.data) && release_tag_name_has_ref) { + if (!(deploy_release && deploy_release.data)) { let try_draft_release; console.log(`Try to get draft release ${release_tag_name} from ${target_owner}/${target_repo}`); try_draft_release = await octokit.rest.repos.listReleases({ owner: target_owner, repo: target_repo, page: 1, - per_page: 100, + per_page: find_draft_release_count, }).then((rsp) => { for (const release of rsp.data || []) { if (release.name == release_tag_name || diff --git a/lib/index.js.map b/lib/index.js.map index d3a3e9d..afb5f59 100755 --- a/lib/index.js.map +++ b/lib/index.js.map @@ -20689,6 +20689,7 @@ async function run() { var release_id = getInputAsInteger("release_id"); var target_owner = getInputAsString("target_owner"); var target_repo = getInputAsString("target_owner"); + const find_draft_release_count = getInputAsInteger("find_draft_release_count") || 32; if (typeof github_token != "string") { action_core.setFailed("token is invalid"); return; @@ -20713,10 +20714,8 @@ async function run() { // action_github.context.repo.owner = xresloader var release_tag_name = "Release-" + action_github.context.sha.substring(0, 8); var release_name = release_tag_name; - var release_tag_name_has_ref = false; if (custom_tag_name) { release_tag_name = custom_tag_name; - release_tag_name_has_ref = true; } else if ((with_branches && with_branches.length > 0) || with_tags) { // check branches or tags @@ -20725,7 +20724,6 @@ async function run() { const match_tag = action_github.context.ref.match(/refs\/tags\/(.*)/); if (match_tag) { match_filter = true; - release_tag_name_has_ref = true; release_tag_name = match_tag[1]; console.log(`Found tag to push: ${match_tag[1]}.`); } @@ -20841,14 +20839,14 @@ async function run() { } } // We can not get a draft release by getReleaseByTag, so we try to find the draft release with the same name by - if (!(deploy_release && deploy_release.data) && release_tag_name_has_ref) { + if (!(deploy_release && deploy_release.data)) { let try_draft_release; console.log(`Try to get draft release ${release_tag_name} from ${target_owner}/${target_repo}`); try_draft_release = await octokit.rest.repos.listReleases({ owner: target_owner, repo: target_repo, page: 1, - per_page: 100, + per_page: find_draft_release_count, }).then((rsp) => { for (const release of rsp.data || []) { if (release.name == release_tag_name || diff --git a/src/index.ts b/src/index.ts index f4069c2..2a0f485 100644 --- a/src/index.ts +++ b/src/index.ts @@ -75,6 +75,7 @@ async function run() { var release_id = getInputAsInteger("release_id"); var target_owner = getInputAsString("target_owner"); var target_repo = getInputAsString("target_owner"); + const find_draft_release_count = getInputAsInteger("find_draft_release_count") || 32; if (typeof github_token != "string") { action_core.setFailed("token is invalid"); @@ -104,10 +105,8 @@ async function run() { var release_tag_name = "Release-" + action_github.context.sha.substring(0, 8); var release_name = release_tag_name; - var release_tag_name_has_ref = false; if (custom_tag_name) { release_tag_name = custom_tag_name; - release_tag_name_has_ref = true; } else if ((with_branches && with_branches.length > 0) || with_tags) { // check branches or tags var match_filter = false; @@ -115,7 +114,6 @@ async function run() { const match_tag = action_github.context.ref.match(/refs\/tags\/(.*)/); if (match_tag) { match_filter = true; - release_tag_name_has_ref = true; release_tag_name = match_tag[1]; console.log(`Found tag to push: ${match_tag[1]}.`); } else { @@ -335,7 +333,7 @@ async function run() { } // We can not get a draft release by getReleaseByTag, so we try to find the draft release with the same name by - if (!(deploy_release && deploy_release.data) && release_tag_name_has_ref) { + if (!(deploy_release && deploy_release.data)) { let try_draft_release: typeof deploy_release; console.log( `Try to get draft release ${release_tag_name} from ${target_owner}/${target_repo}` @@ -344,7 +342,7 @@ async function run() { owner: target_owner, repo: target_repo, page: 1, - per_page: 100, + per_page: find_draft_release_count, }).then((rsp) => { for (const release of rsp.data || []) { if (