Skip to content

Commit

Permalink
feat: add workflow, prod json
Browse files Browse the repository at this point in the history
  • Loading branch information
stillmatic committed Jun 30, 2023
1 parent f9eadd8 commit e143917
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
release:
types: [created]

permissions:
contents: write
packages: write

jobs:
release-linux-amd64:
name: release linux/amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: linux
goarch: amd64
28 changes: 24 additions & 4 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"encoding/json"
"net/http"
"os"
"time"
Expand All @@ -17,6 +18,11 @@ import (
"github.com/stillmatic/featuresheet/gen/featuresheet/v1/featuresheetv1connect"
)

const (
featureSheetVersionKey = "FeatureSheet-Version"
featureSheetVersionValue = "v1"
)

type FeatureSheetServer struct {
fs *featuresheet.FeatureSheet
}
Expand All @@ -35,17 +41,31 @@ func (s *FeatureSheetServer) Evaluate(
res := connect.NewResponse(&fsv1.EvaluateResponse{
Variant: string(fv),
})
res.Header().Set("FeatureSheet-Version", "v1")
res.Header().Set(featureSheetVersionKey, featureSheetVersionValue)
return res, nil
}

func main() {
data, err := os.ReadFile("client_secret.json")
// copy these from client_secret.json
serviceAccountJSON := map[string]interface{}{
"type": "service_account",
"project_id": os.Getenv("GCP_PROJECT_ID"),
"private_key_id": os.Getenv("GCP_PRIVATE_KEY_ID"),
"private_key": os.Getenv("GCP_PRIVATE_KEY"),
"client_email": os.Getenv("GCP_CLIENT_EMAIL"),
"client_id": os.Getenv("GCP_CLIENT_ID"),
"auth_uri": os.Getenv("GCP_AUTH_URI"),
"token_uri": os.Getenv("GCP_TOKEN_URI"),
"auth_provider_x509_cert_url": os.Getenv("GCP_AUTH_PROVIDER_CERT_URL"),
"client_x509_cert_url": os.Getenv("GCP_CLIENT_CERT_URL"),
}

serviceAccountJSONBytes, err := json.Marshal(serviceAccountJSON)
if err != nil {
panic(err)
}

conf, err := google.JWTConfigFromJSON(data, spreadsheet.Scope)
conf, err := google.JWTConfigFromJSON(serviceAccountJSONBytes, spreadsheet.Scope)
if err != nil {
panic(err)
}
Expand All @@ -54,7 +74,7 @@ func main() {
panic("SPREADSHEET_ID env var must be set")
}

client := conf.Client(context.TODO())
client := conf.Client(context.Background())
service := spreadsheet.NewServiceWithClient(client)
fs, err := featuresheet.NewFeatureSheet(service, spreadsheetID, 10*time.Second)
if err != nil {
Expand Down

0 comments on commit e143917

Please sign in to comment.