Skip to content

Commit b5d64d2

Browse files
committed
feat: Add CI/CD pipeline configuration and enhance config loading with file support
1 parent 59cb77d commit b5d64d2

2 files changed

Lines changed: 56 additions & 1 deletion

File tree

.github/workflows/cicd.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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

config/config.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
func 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
}

0 commit comments

Comments
 (0)