diff --git a/README.md b/README.md index e3de457..93af707 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,4 @@ ![result](./public/images/results.png) -- [Deploy Your Java Spring Boot Application on AWS EC2 Using GitHub Actions and Docker](https://betterprogramming.pub/deploy-your-spring-boot-java-application-to-aws-ec2-using-github-actions-and-docker-e28c456a4b1a?source=rss-2612c96405e4------2) - -- [From Open Source Contributor to Google SoC at GitLab](https://medium.com/geekculture/gitlab-google-summer-of-code-e5e819547ee7?source=rss-2612c96405e4------2) - -- [How To Build Your First Chrome Extension in 5 Minutes](https://medium.com/dailyjs/how-to-build-your-first-chrome-extension-in-5-min-1dbe3eb94575?source=rss-2612c96405e4------2) diff --git a/main.go b/main.go index d498d4d..b892f39 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "log" "net/http" "os/exec" + "strings" medium "github.com/readme-update-actions/pkg/structs" helpers "github.com/readme-update-actions/pkg/utils" @@ -101,27 +102,36 @@ func main() { log.Fatalf("Error setting git email %s", err) } - // add to staging area - addCmd := exec.Command("git", "add", readme_path) - err = addCmd.Run() + // check git status + statusCmd, err := exec.Command("git", "status").Output() if err != nil { - log.Fatalf("Error adding to staging area %s", err) - return + log.Fatal(err) } - // do git commit - commitCmd := exec.Command("git", "commit", "-m", commit_message) - err = commitCmd.Run() - if err != nil { - log.Fatalf("Error commiting to repo %s", err) - return - } - - // do git push - pushCmd := exec.Command("git", "push") - err = pushCmd.Run() - if err != nil { - log.Fatalf("Error pushing to repo %s", err) - return + statusOutput := string(statusCmd) + if !strings.Contains(statusOutput, "nothing to commit") { + // add to staging area + addCmd := exec.Command("git", "add", readme_path) + err = addCmd.Run() + if err != nil { + log.Fatalf("Error adding to staging area %s", err) + return + } + + // do git commit + commitCmd := exec.Command("git", "commit", "-m", commit_message) + err = commitCmd.Run() + if err != nil { + log.Fatalf("Error commiting to repo %s", err) + return + } + + // do git push + pushCmd := exec.Command("git", "push") + err = pushCmd.Run() + if err != nil { + log.Fatalf("Error pushing to repo %s", err) + return + } } }