Skip to content

Commit

Permalink
Merge pull request #10 from lowply/add-add-dates
Browse files Browse the repository at this point in the history
Add ADD_DATES option
  • Loading branch information
lowply authored Feb 15, 2020
2 parents e100388 + e89f5c9 commit 1e2d2f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This action opens a new issue from an issue template. It parses the template's f
## Environment variables

- `IFT_TEMPLATE_NAME` (*required*): The name of the issue template. For example, `report.md`. This action will look for the file in the `.github/ISSUE_TEMPLATE` directory.
- `ADD_DATES` (*optional*): Number of the dates to add. This is useful when you want to run this action to open an issue for the next week, not this week.

## Available template variables

Expand Down
11 changes: 10 additions & 1 deletion src/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
"text/template"
"time"
Expand All @@ -24,7 +25,15 @@ type issue struct {
func NewIssue() *issue {
i := &issue{}
i.request = NewRequest(201)
i.date = NewDate(time.Now())
if os.Getenv("ADD_DATES") == "" {
i.date = NewDate(time.Now())
} else {
dates, err := strconv.Atoi(os.Getenv("ADD_DATES"))
if err != nil {
return nil
}
i.date = NewDate(time.Now().AddDate(0, 0, dates))
}
i.endpoint = "https://api.github.com/repos/" + os.Getenv("GITHUB_REPOSITORY") + "/issues"
i.template = filepath.Join(os.Getenv("GITHUB_WORKSPACE"), ".github", "ISSUE_TEMPLATE", os.Getenv("IFT_TEMPLATE_NAME"))
return i
Expand Down

0 comments on commit 1e2d2f0

Please sign in to comment.