Skip to content

Commit

Permalink
add support for backing up Github organisation repos.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhadfield committed Mar 13, 2022
1 parent ee4625f commit de80733
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ go 1.16

require (
github.com/carlescere/scheduler v0.0.0-20170109141437-ee74d2f83d82
github.com/jonhadfield/githosts-utils v0.0.0-20211010090144-dfd3b958eaab
github.com/jonhadfield/githosts-utils v0.0.0-20220313174609-54b364027c38
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0
)

//replace github.com/jonhadfield/githosts-utils => ../githosts-utils
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ github.com/carlescere/scheduler v0.0.0-20170109141437-ee74d2f83d82/go.mod h1:tyA
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/jonhadfield/githosts-utils v0.0.0-20211010090144-dfd3b958eaab h1:r7LW3xQcxeHcF9rHt9eT/VpIYT5Yp4RUDwgb6RNiL9c=
github.com/jonhadfield/githosts-utils v0.0.0-20211010090144-dfd3b958eaab/go.mod h1:PpF4g6DGFG4Fah8yeiPKLCo4qeFibKgYFAVTVkOy5iA=
github.com/jonhadfield/githosts-utils v0.0.0-20220313174609-54b364027c38 h1:9sB3pIS4JXOMY18BAmSBL+etUqXOo9PQa2F3SyMNho0=
github.com/jonhadfield/githosts-utils v0.0.0-20220313174609-54b364027c38/go.mod h1:PpF4g6DGFG4Fah8yeiPKLCo4qeFibKgYFAVTVkOy5iA=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand Down
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/carlescere/scheduler"
githosts "github.com/jonhadfield/githosts-utils"
"github.com/jonhadfield/githosts-utils"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -149,6 +149,12 @@ func run() error {
return errors.New("environment variable GIT_BACKUP_DIR must be set")
}

if _, githubOrgsKeyExists := os.LookupEnv("GITHUB_ORGS"); githubOrgsKeyExists {
if _, githubTokenExists := os.LookupEnv("GITHUB_TOKEN"); !githubTokenExists {
return errors.New("environment variable GITHUB_TOKEN must be set if GITHUB_ORGS is set")
}
}

backupDIR = stripTrailingLineBreak(backupDIR)

_, err := os.Stat(backupDIR)
Expand Down

0 comments on commit de80733

Please sign in to comment.