-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from asetalias/feat/cicd
[feat] added cicd and better env mgmt
- Loading branch information
Showing
4 changed files
with
36 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Fly Deploy | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
deploy: | ||
name: Deploy app | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: flyctl deploy --remote-only | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,38 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/fernet/fernet-go" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
type Config struct { | ||
MongoUri string `mapstructure:"MONGO_URI"` | ||
ServerAddress string `mapstructure:"SERVER_ADDRESS"` | ||
GrpcAddress string `mapstructure:"GRPC_ADDRESS"` | ||
Key string `mapstructure:"KEY"` | ||
FernetKey []*fernet.Key `mapstructure:"FERNET_KEY"` | ||
MongoUri string `mapstructure:"MONGO_URI"` | ||
Key string `mapstructure:"KEY"` | ||
FernetKey []*fernet.Key `mapstructure:"FERNET_KEY"` | ||
} | ||
|
||
func LoadConfig(path string) (config Config, err error) { | ||
viper.AddConfigPath(path) | ||
viper.SetConfigName("app") | ||
viper.AutomaticEnv() | ||
|
||
err = viper.ReadInConfig() | ||
config.MongoUri, err = getEnvVar("MONGO_URI") | ||
if err != nil { | ||
return | ||
} | ||
|
||
err = viper.Unmarshal(&config) | ||
config.Key, err = getEnvVar("KEY") | ||
if err != nil { | ||
return | ||
} | ||
|
||
config.GrpcAddress = "amizone.fly.dev:443" | ||
|
||
config.FernetKey = fernet.MustDecodeKeys(config.Key) | ||
|
||
return | ||
} | ||
|
||
func getEnvVar(key string) (string, error) { | ||
value := os.Getenv(key) | ||
if value == "" { | ||
return "", fmt.Errorf("%s environment variable not set", key) | ||
} | ||
return value, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters