Skip to content

Commit

Permalink
Addition of custom user +email + commit msg
Browse files Browse the repository at this point in the history
  • Loading branch information
Arisamiga committed Dec 16, 2023
1 parent b5bcc8b commit e98bda1
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 16 deletions.
11 changes: 10 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
feed_list: # Url of RSS
description: "RSS Link"
required: true
ln_access_token: # Url of LinkedIn Access Token
ln_access_token: # LinkedIn Access Token
description: "LinkedIn Access Token | Can be Generated at (https://www.linkedin.com/developers/tools/oauth/)"
required: true
embed_image: # Url of embed image
Expand All @@ -14,6 +14,15 @@ inputs:
last_post_path: # Path to the file that stores the last post (Default: .github/.lastPost.txt)
description: "Path to the file that stores the last post"
required: false
commit_user: # Username of the commiter
description: "Username of commit user"
required: false
commit_email: # Email of the commiter
description: "Email of commit user"
required: false
commit_message: # Commit message
description: "Commit message"
required: false
runs:
using: "node16"
main: "dist/index.js"
Expand Down
35 changes: 28 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

35 changes: 28 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const feedList = core.getInput("feed_list");
const embedImage = core.getInput("embed_image");
const lastPostPath = core.getInput("last_post_path");

const commitUser = core.getInput("commit_user");
const commitEmail = core.getInput("commit_email");
const commitMessage = core.getInput("commit_message");

// Get LinkedIn ID, i.e. ownerId
function getLinkedinId(accessToken) {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -72,14 +76,31 @@ function wasPostPublished(feed) {

// push the file changes to repository
const { exec } = require("child_process");
exec(
"git config --global user.email " +
process.env.GITHUB_ACTOR +
"@users.noreply.github.com"
);
exec("git config --global user.name " + process.env.GITHUB_ACTOR);

if (commitEmail) {
exec("git config --global user.email " + commitEmail);
} else {
exec(
"git config --global user.email " +
process.env.GITHUB_ACTOR +
"@users.noreply.github.com"
);
}

if (commitUser) {
exec("git config --global user.name " + commitUser);
} else {
exec("git config --global user.name " + process.env.GITHUB_ACTOR);
}

exec("git add .");
exec("git commit -m 'Update Last Post File'");

if (commitMessage) {
exec("git commit -m '" + commitMessage + "'");
} else {
exec("git commit -m 'Update Last Post File'");
}

exec("git push");

return false;
Expand Down

0 comments on commit e98bda1

Please sign in to comment.