File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : CI/CD Pipeline
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ branches :
9+ - main
10+
11+ jobs :
12+ test :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Checkout code
16+ uses : actions/checkout@v3
17+
18+ - name : Set up Node.js
19+ uses : actions/setup-node@v3
20+ with :
21+ node-version : ' 16'
22+
23+ - name : Install dependencies
24+ run : npm install
25+
26+ - name : Run tests
27+ run : npm test
28+
29+ build :
30+ runs-on : ubuntu-latest
31+ needs : test
32+ if : success()
33+ steps :
34+ - name : Checkout code
35+ uses : actions/checkout@v3
36+
37+ - name : Set up Node.js
38+ uses : actions/setup-node@v3
39+ with :
40+ node-version : ' 16'
41+
42+ - name : Install dependencies
43+ run : npm install
44+
45+ - name : Build application
46+ run : npm run build
Original file line number Diff line number Diff line change 88
99func NewConfig () * viper.Viper {
1010 conf := viper .New ()
11+ conf .AutomaticEnv ()
1112
1213 conf .SetEnvKeyReplacer (strings .NewReplacer ("." , "_" ))
1314
@@ -35,7 +36,15 @@ func NewConfig() *viper.Viper {
3536 conf .SetDefault ("log.format" , "json" )
3637 conf .SetDefault ("log.level" , "info" )
3738
38- conf .AutomaticEnv ()
39+ // Config file
40+ conf .SetConfigName ("config" ) // nome do arquivo sem extensão
41+ conf .SetConfigType ("yaml" ) // ou json, toml, etc.
42+ conf .AddConfigPath ("." ) // onde procurar o arquivo
43+
44+ if err := conf .ReadInConfig (); err != nil {
45+ // Se não achar o arquivo, apenas logar (não falhar)
46+ // fmt.Println("No config file found, using defaults and envs")
47+ }
3948
4049 return conf
4150}
You can’t perform that action at this time.
0 commit comments