update init: add .env, update docs: git credentials
This commit is contained in:
parent
142869ae84
commit
077d37df7a
|
@ -9,5 +9,6 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
dist/
|
||||||
|
|
||||||
|
*.bak
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.*.sw*
|
.*.sw*
|
||||||
|
|
24
README.md
24
README.md
|
@ -67,15 +67,37 @@ curl -sS https://webinstall.dev/gitdeploy | bash
|
||||||
curl -A MS https://webinstall.dev/gitdeploy | powershell
|
curl -A MS https://webinstall.dev/gitdeploy | powershell
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Git SSH Deploy Keys and Tokens
|
||||||
|
|
||||||
|
All of the clone URLs are HTTPS clone URLs.
|
||||||
|
|
||||||
|
To use SSH clone URLs, you should update your git credentials:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git config --global url."ssh://git@github.com/example-org/".insteadOf "https://github.com/example-org/"
|
||||||
|
```
|
||||||
|
|
||||||
|
This will add an entry like this to your `.gitconfig`:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[url "ssh://git@github.com/example-org/"]
|
||||||
|
insteadOf = https://github.com/example-org/
|
||||||
|
```
|
||||||
|
|
||||||
|
For more info see
|
||||||
|
[The Git Credentials Cheat Sheet](https://coolaj86.com/articles/vanilla-devops-git-credentials-cheatsheet/)
|
||||||
|
at <https://coolaj86.com/articles/vanilla-devops-git-credentials-cheatsheet/>.
|
||||||
|
|
||||||
## Setup with Deploy Scripts
|
## Setup with Deploy Scripts
|
||||||
|
|
||||||
Start by initializing your `./scripts` directory.
|
Start by initializing your `.env` and `./scripts` directory.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gitdeploy init
|
gitdeploy init
|
||||||
```
|
```
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
|
.env
|
||||||
scripts/
|
scripts/
|
||||||
├── deploy.sh
|
├── deploy.sh
|
||||||
├── git.example.com/org/go-project/deploy.sh
|
├── git.example.com/org/go-project/deploy.sh
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# PORT only listens on localhost
|
# PORT only listens on localhost
|
||||||
PORT=4483
|
#PORT=4483
|
||||||
|
|
||||||
# LISTEN lets you choose the interface also
|
# LISTEN lets you choose the interface also
|
||||||
#LISTEN=0.0.0.0:4483
|
#LISTEN=0.0.0.0:4483
|
||||||
|
@ -7,12 +7,13 @@ PORT=4483
|
||||||
# List promotions in descending order
|
# List promotions in descending order
|
||||||
PROMOTIONS="production staging master"
|
PROMOTIONS="production staging master"
|
||||||
|
|
||||||
|
# Whether to trust X-Forward-* headers
|
||||||
TRUST_PROXY=false
|
TRUST_PROXY=false
|
||||||
|
|
||||||
# These repos will be trusted to run .gitdeploy/deploy.sh
|
# These repos will be trusted to run .gitdeploy/deploy.sh
|
||||||
TRUST_REPOS=git.example.com/org/project,git.example.com/org/other-project
|
#TRUST_REPOS=git.example.com/org/project,git.example.com/org/other-project
|
||||||
|
|
||||||
# List your various webhook secrets
|
# List your various webhook secrets
|
||||||
GITHUB_SECRET=xxxxxxxxxxxxxxxxxxxxxx,yyyyyyyyyyyyyyyyyy
|
#GITHUB_SECRET=xxxxxxxxxxxxxxxxxxxxxx,yyyyyyyyyyyyyyyyyy
|
||||||
GITEA_SECRET=xxxxxxxxxxxxxxxxxxxxxx
|
#GITEA_SECRET=xxxxxxxxxxxxxxxxxxxxxx
|
||||||
BITBUCKET_SECRET=xxxxxxxxxxxxxxxxxxxxxx
|
#BITBUCKET_SECRET=xxxxxxxxxxxxxxxxxxxxxx
|
||||||
|
|
78
main.go
78
main.go
|
@ -14,11 +14,11 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rootprojects.org/root/vfscopy"
|
|
||||||
"git.rootprojects.org/root/gitdeploy/assets/public"
|
|
||||||
"git.rootprojects.org/root/gitdeploy/assets/examples"
|
"git.rootprojects.org/root/gitdeploy/assets/examples"
|
||||||
|
"git.rootprojects.org/root/gitdeploy/assets/public"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/options"
|
"git.rootprojects.org/root/gitdeploy/internal/options"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
||||||
|
"git.rootprojects.org/root/vfscopy"
|
||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
"github.com/go-chi/chi/middleware"
|
"github.com/go-chi/chi/middleware"
|
||||||
|
@ -124,29 +124,7 @@ func main() {
|
||||||
return
|
return
|
||||||
case "init":
|
case "init":
|
||||||
_ = initFlags.Parse(args[2:])
|
_ = initFlags.Parse(args[2:])
|
||||||
vfs := vfscopy.NewVFS(examples.Assets)
|
gdInit()
|
||||||
_, err := os.Open("scripts")
|
|
||||||
if nil == err {
|
|
||||||
fmt.Fprintf(os.Stderr, "./scripts already exists\n")
|
|
||||||
os.Exit(1)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println("Copying ...")
|
|
||||||
if err := vfscopy.CopyAll(vfs, ".", "./scripts", vfscopy.Options {
|
|
||||||
Skip: func (path string) (bool, error) {
|
|
||||||
f, _ := vfs.Open(path)
|
|
||||||
fi, _ := f.Stat()
|
|
||||||
if !fi.IsDir() {
|
|
||||||
fmt.Println(" scripts/" + path)
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
},
|
|
||||||
}); nil != err {
|
|
||||||
fmt.Fprintf(os.Stderr, "error initializing ./scripts directory\n")
|
|
||||||
os.Exit(1)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println("Done.")
|
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
return
|
return
|
||||||
case "run":
|
case "run":
|
||||||
|
@ -171,6 +149,12 @@ func main() {
|
||||||
if 0 == len(runOpts.Addr) {
|
if 0 == len(runOpts.Addr) {
|
||||||
runOpts.Addr = os.Getenv("LISTEN")
|
runOpts.Addr = os.Getenv("LISTEN")
|
||||||
}
|
}
|
||||||
|
if 0 == len(runOpts.Addr) {
|
||||||
|
port := os.Getenv("PORT")
|
||||||
|
if len(port) > 0 {
|
||||||
|
runOpts.Addr = "localhost:" + port
|
||||||
|
}
|
||||||
|
}
|
||||||
if 0 == len(runOpts.Addr) {
|
if 0 == len(runOpts.Addr) {
|
||||||
runOpts.Addr = "localhost:4483"
|
runOpts.Addr = "localhost:4483"
|
||||||
}
|
}
|
||||||
|
@ -219,6 +203,50 @@ type KillMsg struct {
|
||||||
Kill bool `json:"kill"`
|
Kill bool `json:"kill"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func gdInit() {
|
||||||
|
vfs := vfscopy.NewVFS(examples.Assets)
|
||||||
|
_, err := os.Open("scripts")
|
||||||
|
fmt.Println("Initiazing ...")
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
|
fmt.Fprintf(os.Stderr, " skip: ./scripts already exists\n")
|
||||||
|
} else {
|
||||||
|
if err := vfscopy.CopyAll(vfs, ".", "./scripts", vfscopy.Options{
|
||||||
|
AddPermission: os.FileMode(0600),
|
||||||
|
Skip: func(path string) (bool, error) {
|
||||||
|
if strings.HasSuffix(path, "/dotenv") {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
f, _ := vfs.Open(path)
|
||||||
|
fi, _ := f.Stat()
|
||||||
|
if !fi.IsDir() {
|
||||||
|
fmt.Println(" copy: scripts/" + path)
|
||||||
|
}
|
||||||
|
return false, nil
|
||||||
|
},
|
||||||
|
}); nil != err {
|
||||||
|
fmt.Fprintf(os.Stderr, "error initializing ./scripts directory: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err = os.Open(".env")
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
|
fmt.Fprintf(os.Stderr, " skip: ./.env already exists\n")
|
||||||
|
} else {
|
||||||
|
if err := vfscopy.CopyAll(vfs, "dotenv", ".env", vfscopy.Options{
|
||||||
|
AddPermission: os.FileMode(0600),
|
||||||
|
}); nil != err {
|
||||||
|
fmt.Fprintf(os.Stderr, "error initializing ./.env file: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_ = os.Chmod(".env", 0600)
|
||||||
|
fmt.Println(" copy: .env")
|
||||||
|
}
|
||||||
|
fmt.Println("Done.")
|
||||||
|
}
|
||||||
|
|
||||||
func serve() {
|
func serve() {
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue