From c34ab3f603076203cd7895d354b608bc4022bfc3 Mon Sep 17 00:00:00 2001 From: Shubham Kumar Date: Sat, 24 Feb 2024 22:14:37 +0100 Subject: [PATCH] chore: testing my contributions workflow v0.3 --- contributions.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/contributions.rb b/contributions.rb index c55da2f..7b35c9e 100644 --- a/contributions.rb +++ b/contributions.rb @@ -24,15 +24,23 @@ def run # Update README.md with the count # readme_path = File.join(__dir__, 'README.md') readme_path = ENV['INPUT_README_PATH'] + git_username = ENV['INPUT_COMMIT_USER'] + git_email = ENV['INPUT_COMMIT_EMAIL'] + readme_content = File.read(readme_path) updated_readme_content = readme_content.gsub(/MERGED_PULL_REQUESTS_COUNT/, merged_count.to_s) File.write(readme_path, updated_readme_content) # git flow commit_message = ENV['INPUT_COMMIT_MESSAGE'] || 'Update README.md' - `git add #{readme_path}` - `git commit -m "#{commit_message}"` - `git push origin HEAD` + `git config user.name #{git_username}` + `git config user.email #{git_email}` + status = `git status` + if !status.includes?("nothing to commit") + `git add #{readme_path}` + `git commit -m "#{commit_message}"` + `git push origin HEAD` + end else puts "Failed to retrieve merged pull requests: #{res.code} - #{res.message}" end