-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3027fc4
commit bc41bd6
Showing
12 changed files
with
3,567 additions
and
45 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,2 @@ | ||
node_modules | ||
.next |
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,51 +1,27 @@ | ||
name: Azure Static Web Apps CI/CD | ||
name: Publish Docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, synchronize, reopened, closed] | ||
branches: | ||
- main | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
test: | ||
permissions: | ||
checks: write | ||
uses: ./.github/workflows/main.yml | ||
|
||
deploy: | ||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
needs: [ test ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a | ||
with: | ||
submodules: true | ||
lfs: false | ||
- name: Build And Deploy | ||
id: builddeploy | ||
uses: Azure/static-web-apps-deploy@v1 | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- id: meta | ||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | ||
with: | ||
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_JOLLY_FIELD_066760403 }} | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) | ||
action: "upload" | ||
###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### | ||
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig | ||
app_location: "/" # App source code path | ||
api_location: "" # Api source code path - optional | ||
output_location: "" # Built app content directory - optional | ||
###### End of Repository/Build Configurations ###### | ||
|
||
close_pull_request_job: | ||
if: github.event_name == 'pull_request' && github.event.action == 'closed' | ||
runs-on: ubuntu-latest | ||
name: Close Pull Request Job | ||
steps: | ||
- name: Close Pull Request | ||
id: closepullrequest | ||
uses: Azure/static-web-apps-deploy@v1 | ||
images: zeiss/service-lens | ||
- uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 | ||
with: | ||
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_JOLLY_FIELD_066760403 }} | ||
action: "close" | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"os" | ||
|
||
"github.com/katallaxie/pkg/logger" | ||
"github.com/spf13/cobra" | ||
"github.com/zeiss/service-lens/internal/adapters" | ||
"gorm.io/driver/postgres" | ||
"gorm.io/gorm" | ||
) | ||
|
||
// DB ... | ||
type DB struct { | ||
Username string | ||
Password string | ||
Port int | ||
Database string | ||
Host string | ||
} | ||
|
||
// Flags contains the command line flags. | ||
type Flags struct { | ||
Addr string | ||
DB *DB | ||
} | ||
|
||
// New ... | ||
func New() *Config { | ||
return &Config{ | ||
Flags: &Flags{ | ||
DB: &DB{ | ||
Username: "example", | ||
Password: "example", | ||
Port: 5432, | ||
Database: "example", | ||
Host: "host.docker.internal", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
// Config ... | ||
type Config struct { | ||
Flags *Flags | ||
} | ||
|
||
// Cwd returns the current working directory. | ||
func (c *Config) Cwd() (string, error) { | ||
return os.Getwd() | ||
} | ||
|
||
var cfg = New() | ||
|
||
var ( | ||
version = "dev" | ||
commit = "none" | ||
date = "unknown" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return run(cmd.Context()) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.PersistentFlags().StringVar(&cfg.Flags.Addr, "addr", ":8080", "addr") | ||
rootCmd.PersistentFlags().StringVar(&cfg.Flags.DB.Database, "db-database", cfg.Flags.DB.Database, "Database name") | ||
rootCmd.PersistentFlags().StringVar(&cfg.Flags.DB.Username, "db-username", cfg.Flags.DB.Username, "Database user") | ||
rootCmd.PersistentFlags().StringVar(&cfg.Flags.DB.Password, "db-password", cfg.Flags.DB.Password, "Database password") | ||
rootCmd.PersistentFlags().IntVar(&cfg.Flags.DB.Port, "db-port", cfg.Flags.DB.Port, "Database port") | ||
|
||
rootCmd.SilenceUsage = true | ||
} | ||
|
||
func main() { | ||
if err := rootCmd.Execute(); err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func run(ctx context.Context) error { | ||
log.SetFlags(0) | ||
log.SetOutput(os.Stderr) | ||
|
||
logger.RedirectStdLog(logger.LogSink) | ||
|
||
dsn := "host=host.docker.internal user=example password=example dbname=example port=5432 sslmode=disable" | ||
conn, err := gorm.Open(postgres.Open(dsn), &gorm.Config{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
db := adapters.NewDB(conn) | ||
err = db.RunMigration() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.