diff --git a/action/index.js b/action/index.js index 9850da2..140961c 100644 --- a/action/index.js +++ b/action/index.js @@ -12430,8 +12430,6 @@ const run = async () => { } ); - let commits = ""; - if (compare_commits?.data?.commits?.length === 0) { commits = ""; return; @@ -12453,6 +12451,8 @@ const run = async () => { console.log(error?.message); } + console.log(commits); + // attempt to create PR try { let options = { @@ -12476,28 +12476,31 @@ const run = async () => { }, ], }; - const createpr = await createorupdatepr({ - branch: branch_name, - body: commits, - owner: context.payload?.repository?.owner?.login, - repo: context.payload?.repository?.name, - full_name: context.payload?.repository?.full_name, - }); - if (createpr?.data) { - axios - .post(SLACK_WEBHOOK_URL, JSON.stringify(options)) - .then((response) => { - console.log("SUCCEEDED: Sent slack webhook", response.data); - }) - .catch((error) => { - console.log("FAILED: Send slack webhook", error); - }); - return; + if (commits != "") { + const createpr = await createorupdatepr({ + branch: branch_name, + body: commits, + owner: context.payload?.repository?.owner?.login, + repo: context.payload?.repository?.name, + full_name: context.payload?.repository?.full_name, + }); + if (createpr?.data) { + axios + .post(SLACK_WEBHOOK_URL, JSON.stringify(options)) + .then((response) => { + console.log("SUCCEEDED: Sent slack webhook", response.data); + }) + .catch((error) => { + console.log("FAILED: Send slack webhook", error); + }); + return; + } + } else { + console.log("No commits to create this PR"); } } catch (error) { console.log("error", error?.message); } - // update PR try { const options = { diff --git a/changelog.md b/changelog.md index c9c3580..0e5c8d9 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,11 @@ +# 1.0.2 +* test bump version actions +# 1.0.1 +* test manually update version + +* reset bump version actions +# 1.0.1 +* new test # 1.0.1 * fix typo # 1.0.1 diff --git a/package.json b/package.json index d0ea6f6..d367312 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "automate-pull-request", - "version": "1.0.6", + "version": "1.0.2", "description": "", "main": "index.js", "scripts": { diff --git a/src/actions.js b/src/actions.js index d77c653..677bc68 100644 --- a/src/actions.js +++ b/src/actions.js @@ -33,8 +33,6 @@ const run = async () => { } ); - let commits = ""; - if (compare_commits?.data?.commits?.length === 0) { commits = ""; return; @@ -56,6 +54,8 @@ const run = async () => { console.log(error?.message); } + console.log(commits); + // attempt to create PR try { let options = { @@ -79,23 +79,27 @@ const run = async () => { }, ], }; - const createpr = await createorupdatepr({ - branch: branch_name, - body: commits, - owner: context.payload?.repository?.owner?.login, - repo: context.payload?.repository?.name, - full_name: context.payload?.repository?.full_name, - }); - if (createpr?.data) { - axios - .post(SLACK_WEBHOOK_URL, JSON.stringify(options)) - .then((response) => { - console.log("SUCCEEDED: Sent slack webhook", response.data); - }) - .catch((error) => { - console.log("FAILED: Send slack webhook", error); - }); - return; + if (commits != "") { + const createpr = await createorupdatepr({ + branch: branch_name, + body: commits, + owner: context.payload?.repository?.owner?.login, + repo: context.payload?.repository?.name, + full_name: context.payload?.repository?.full_name, + }); + if (createpr?.data) { + axios + .post(SLACK_WEBHOOK_URL, JSON.stringify(options)) + .then((response) => { + console.log("SUCCEEDED: Sent slack webhook", response.data); + }) + .catch((error) => { + console.log("FAILED: Send slack webhook", error); + }); + return; + } + } else { + console.log("No commits to create this PR"); } } catch (error) { console.log("error", error?.message);