-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add blogs to readme * feat: Add codeowners * fix: Fix lint issue
- Loading branch information
Showing
6 changed files
with
125 additions
and
33 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @imskr |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# ReadMe-Blogs | ||
Fetch latest blog posts and add it to GitHub profile's readME dynamically | ||
|
||
<!-- BLOG-LIST-START --> | ||
<!-- BLOG-LIST-END --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,33 @@ name: "Readme update Actions" | |
description: "Fetch latest blog posts and add it to GitHub profile's readme dynamically" | ||
author: "Shubham Kumar" | ||
inputs: | ||
readme_path: | ||
max_post: | ||
rss_list: | ||
description: "RSS feed url" | ||
default: "" | ||
required: true | ||
readme_path: | ||
description: "Path of readme file" | ||
default: "./README.md" | ||
required: false | ||
max_post: | ||
description: "Max number of posts" | ||
default: "3" | ||
required: false | ||
commit_user: | ||
description: "Git username" | ||
default: "imskr" | ||
required: false | ||
commit_email: | ||
description: "Git user email" | ||
default: "[email protected]" | ||
required: false | ||
commit_message: | ||
description: "Git commit message" | ||
default: "Update readme with latest blogs" | ||
required: false | ||
outputs: | ||
result_post: | ||
description: "Stringified posts in readme format" | ||
|
||
runs: | ||
using: "docker" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package helpers | ||
|
||
import ( | ||
"errors" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// create new error for empty env | ||
var ErrEnvEmpty = errors.New("getenv: Environment variable empty") | ||
|
||
// Get env string from user through actions env | ||
// if no env variables provided throw error | ||
// requires key string | ||
// returns string, error | ||
func GetEnvString(key string) (string, error) { | ||
env_string := os.Getenv(key) | ||
if env_string == "" { | ||
return env_string, ErrEnvEmpty | ||
} | ||
return env_string, nil | ||
} | ||
|
||
// Get env string from user through actions env and convert to integer | ||
// if no env variables provided throw error | ||
// requires key string | ||
// returns int, error | ||
func GetEnvInteger(key string) (int, error) { | ||
strEnv, err := GetEnvString(key) | ||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
intEnv, err := strconv.Atoi(strEnv) | ||
if err != nil { | ||
return 0, err | ||
} | ||
return intEnv, nil | ||
} | ||
|
||
// Read a file and replace strings | ||
// requires path of file, resultString | ||
// returns error | ||
func ReplaceFile(path string, resultString string) error { | ||
input, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
lines := strings.Split(string(input), "\n") | ||
|
||
for i, line := range lines { | ||
if strings.Contains(line, "<!-- BLOG-LIST-START -->") { | ||
lines[i] = resultString | ||
} | ||
} | ||
|
||
output := strings.Join(lines, "\n") | ||
err = ioutil.WriteFile(path, []byte(output), 0644) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
return nil | ||
} |