From 4e95785346b35e4c9db045a255d6ef50ce1ea2bb Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 16:33:54 -0700 Subject: [PATCH 01/29] changed README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b..d003f6e700 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,5 @@ go build -o notely && ./notely *This starts the server in non-database mode.* It will serve a simple webpage at `http://localhost:8080`. You do *not* need to set up a database or any interactivity on the webpage yet. Instructions for that will come later in the course! + +Eric's version of Boot.dev's Notely app. From d1241fd12bf2e6e09befdb33f5764a5eb661a8eb Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 16:44:13 -0700 Subject: [PATCH 02/29] ci.yml file --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..f48b49e05b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: ci + +on: + pull_request: + branches: [main] + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.23.0" + + - name: Force Failure + run: (exit 1) \ No newline at end of file From 82952e444ce36ab2ab98054475ecea474d94bbc1 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 16:46:42 -0700 Subject: [PATCH 03/29] run go version in ci.yml file --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f48b49e05b..8fc64b410f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.23.0" - - name: Force Failure - run: (exit 1) \ No newline at end of file + - name: Run go version + run: go version \ No newline at end of file From 04bf27e2e1b6603ca9404a9d65bc9b04cdf5c0d1 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 17:31:38 -0700 Subject: [PATCH 04/29] added auth_test.go for testing GetAPiKey function --- internal/auth/auth_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 internal/auth/auth_test.go diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go new file mode 100644 index 0000000000..db38c74ee8 --- /dev/null +++ b/internal/auth/auth_test.go @@ -0,0 +1,24 @@ +package auth + +import ( + "net/http" + "testing" +) + +func TestCorrectAPIKey(t *testing.T) { + req, _ := http.NewRequest("GET", "/", nil) + req.Header.Set("Authorization", "ApiKey zesxrctfvygbunijmo78516zesxdfjnimkop") + + actual_key, err := GetAPIKey(req.Header) + if actual_key != "zesxrctfvygbunijmo78516zesxdfjnimkop" || err != nil { + t.Errorf("incorrect or missing key") + } +} + +func TestMissingHeader(t *testing.T) { + req, _ := http.NewRequest("GET", "/", nil) + actual_key, err := GetAPIKey(req.Header) + if actual_key != "" || err == nil { + t.Errorf("expected empty key and an error when header is missing, got key=%q, err=%v", actual_key, err) + } +} From 92717fe734064a38419eaf65a022e652d5c4dbaa Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 17:39:41 -0700 Subject: [PATCH 05/29] breaking GetApiKey function on purpose for testing, splitAuth[2] --- .github/workflows/ci.yml | 2 +- internal/auth/auth.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fc64b410f..581f8cd420 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.23.0" - name: Run go version - run: go version \ No newline at end of file + run: go test ./ \ No newline at end of file diff --git a/internal/auth/auth.go b/internal/auth/auth.go index f969aacf63..21bf62218e 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -19,5 +19,5 @@ func GetAPIKey(headers http.Header) (string, error) { return "", errors.New("malformed authorization header") } - return splitAuth[1], nil + return splitAuth[2], nil } From efd5b964efb368d08bf696320f1c45f9f6a3d318 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 17:41:52 -0700 Subject: [PATCH 06/29] breaking getapikey function --- internal/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 21bf62218e..6ab098bb8c 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -19,5 +19,5 @@ func GetAPIKey(headers http.Header) (string, error) { return "", errors.New("malformed authorization header") } - return splitAuth[2], nil + return splitAuth, nil } From 46fd83d7354e07c710e7d64d82177ec3c8f860db Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 17:43:21 -0700 Subject: [PATCH 07/29] fixing broken function for test --- internal/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 6ab098bb8c..21bf62218e 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -19,5 +19,5 @@ func GetAPIKey(headers http.Header) (string, error) { return "", errors.New("malformed authorization header") } - return splitAuth, nil + return splitAuth[2], nil } From 29cc675ac4e49565fbb8e8a2d7492208ff351386 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 17:46:59 -0700 Subject: [PATCH 08/29] added -cover flag to go test CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 581f8cd420..d664d2f291 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.23.0" - name: Run go version - run: go test ./ \ No newline at end of file + run: go test -cover ./ \ No newline at end of file From 3e8bdbdc840a5cdaec623bab6fa0363fe5f53891 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 17:48:49 -0700 Subject: [PATCH 09/29] fixing errors from break --- internal/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 21bf62218e..f969aacf63 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -19,5 +19,5 @@ func GetAPIKey(headers http.Header) (string, error) { return "", errors.New("malformed authorization header") } - return splitAuth[2], nil + return splitAuth[1], nil } From 5b050eb23a7cf75cbec84e1b055a2676591a58f8 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 17:53:28 -0700 Subject: [PATCH 10/29] added testing badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d003f6e700..1b887a7ed6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![Tests status badge](https://github.com/epenick123/learn-cicd-starter/actions/workflows/ci.yml/badge.svg) + # learn-cicd-starter (Notely) This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). From 283312743cbfa79aaa338ece6be459ccf9911802 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 18:18:18 -0700 Subject: [PATCH 11/29] updated ci.yml to add new Style formatting test --- .github/workflows/ci.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d664d2f291..b71261187d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,19 @@ jobs: go-version: "1.23.0" - name: Run go version - run: go test -cover ./ \ No newline at end of file + run: go test -cover ./ + style: + name: Style + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.23.0" + + - name: Style + run: test -z $(go fmt ./...) \ No newline at end of file From dfaecc836d33091926b808c42d5c6bd3eb67d9a5 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Tue, 5 Aug 2025 18:25:09 -0700 Subject: [PATCH 12/29] added style test to ci.yml --- .github/workflows/ci.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d664d2f291..b71261187d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,19 @@ jobs: go-version: "1.23.0" - name: Run go version - run: go test -cover ./ \ No newline at end of file + run: go test -cover ./ + style: + name: Style + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.23.0" + + - name: Style + run: test -z $(go fmt ./...) \ No newline at end of file From 71934435a081626c506ad6d510f0eaa650f66854 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Wed, 6 Aug 2025 14:06:17 -0700 Subject: [PATCH 13/29] add staticcheck to ci.yml in the style job --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b71261187d..441cc92a9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,4 +34,7 @@ jobs: go-version: "1.23.0" - name: Style - run: test -z $(go fmt ./...) \ No newline at end of file + run: test -z $(go fmt ./...) + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest \ No newline at end of file From 05e331631830d1eeb51106f2b2b22862655c88e8 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Wed, 6 Aug 2025 14:16:33 -0700 Subject: [PATCH 14/29] added test unused function in main and run staticcheck step to ci.yml --- .github/workflows/ci.yml | 5 ++++- main.go | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 441cc92a9b..cff2b27577 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,4 +37,7 @@ jobs: run: test -z $(go fmt ./...) - name: Install staticcheck - run: go install honnef.co/go/tools/cmd/staticcheck@latest \ No newline at end of file + run: go install honnef.co/go/tools/cmd/staticcheck@latest + + - name: Run staticcheck + run: staticcheck ./... \ No newline at end of file diff --git a/main.go b/main.go index 19d7366c5f..a621713c2b 100644 --- a/main.go +++ b/main.go @@ -96,3 +96,8 @@ func main() { log.Printf("Serving on port: %s\n", port) log.Fatal(srv.ListenAndServe()) } + +func unused() { + // this function does nothing + // and is called nowhere +} From 291555c0ac1dd47f47ff56ea1743c679b12f4b29 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Wed, 6 Aug 2025 14:30:03 -0700 Subject: [PATCH 15/29] add gosec to ci.yml --- .github/workflows/ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cff2b27577..25dc825c7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,4 +40,10 @@ jobs: run: go install honnef.co/go/tools/cmd/staticcheck@latest - name: Run staticcheck - run: staticcheck ./... \ No newline at end of file + run: staticcheck ./... + + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest + + - name: Run gosec + run: gosec ./... \ No newline at end of file From 7a7a4e1b40bb7b5f688af35422b5a10e45c15839 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Wed, 6 Aug 2025 14:33:05 -0700 Subject: [PATCH 16/29] moving gosec in ci.yml --- .github/workflows/ci.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25dc825c7b..1edb331966 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,13 @@ jobs: - name: Run go version run: go test -cover ./ + + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest + + - name: Run gosec + run: gosec ./... + style: name: Style runs-on: ubuntu-latest @@ -42,8 +49,4 @@ jobs: - name: Run staticcheck run: staticcheck ./... - - name: Install gosec - run: go install github.com/securego/gosec/v2/cmd/gosec@latest - - - name: Run gosec - run: gosec ./... \ No newline at end of file + \ No newline at end of file From fa6e4938e4159e2fe9d92993ca41aef919bdc3c7 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Wed, 6 Aug 2025 15:00:15 -0700 Subject: [PATCH 17/29] removed unused function, fixed gosec security issues --- json.go | 6 +++++- main.go | 11 ++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/json.go b/json.go index 1e6e7985e1..a2973c77ed 100644 --- a/json.go +++ b/json.go @@ -30,5 +30,9 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) { return } w.WriteHeader(code) - w.Write(dat) + _, err = w.Write(dat) + if err != nil { + // Log the error or handle it appropriately + log.Printf("Error writing response: %v", err) + } } diff --git a/main.go b/main.go index a621713c2b..b3a4ade65d 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "log" "net/http" "os" + "time" "github.com/go-chi/chi" "github.com/go-chi/cors" @@ -89,15 +90,11 @@ func main() { router.Mount("/v1", v1Router) srv := &http.Server{ - Addr: ":" + port, - Handler: router, + Addr: ":" + port, + Handler: router, + ReadHeaderTimeout: 30 * time.Second, } log.Printf("Serving on port: %s\n", port) log.Fatal(srv.ListenAndServe()) } - -func unused() { - // this function does nothing - // and is called nowhere -} From 1354f2312cc510891666f07a007f4115fb64020c Mon Sep 17 00:00:00 2001 From: epenick123 Date: Wed, 6 Aug 2025 17:19:26 -0700 Subject: [PATCH 18/29] added cd.yml and set up buildprod --- .github/workflows/cd.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000000..d5f01b9a7a --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,22 @@ +name: cd + +on: + push: + branches: [main] + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.23.0" + + - name: Build app + run: scripts/buildprod.sh \ No newline at end of file From 6c6308af0873671b561f6d9edccfa19bd4a99a82 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Wed, 6 Aug 2025 18:57:10 -0700 Subject: [PATCH 19/29] set up google cloud sdk in cd.yml --- .github/workflows/cd.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index d5f01b9a7a..deea55b94b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -19,4 +19,18 @@ jobs: go-version: "1.23.0" - name: Build app - run: scripts/buildprod.sh \ No newline at end of file + run: scripts/buildprod.sh + + + - id: 'auth' + uses: 'google-github-actions/auth@v2' + with: + credentials_json: '${{ secrets.GCP_CREDENTIALS }}' + + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v2' + with: + version: '>= 363.0.0' + + - name: Build and push Docker image + run: gcloud builds submit --tag us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest . \ No newline at end of file From ea0228b88c61289e826f47a71476f156fc3717c9 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Thu, 7 Aug 2025 15:02:39 -0700 Subject: [PATCH 20/29] add google cloud run to cd.yml and update index.html --- static/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/index.html b/static/index.html index 72be101028..5d4ad73c09 100644 --- a/static/index.html +++ b/static/index.html @@ -7,7 +7,7 @@ -

Notely

+

Welcome to Notely

From 865b81a4947cb67abf6b17ed0c6c20ffe403dbde Mon Sep 17 00:00:00 2001 From: epenick123 Date: Thu, 7 Aug 2025 15:25:41 -0700 Subject: [PATCH 21/29] changing Dockerfile and cd.yml --- .github/workflows/cd.yml | 5 ++++- Dockerfile | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index deea55b94b..13e91f53d1 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -33,4 +33,7 @@ jobs: version: '>= 363.0.0' - name: Build and push Docker image - run: gcloud builds submit --tag us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest . \ No newline at end of file + run: gcloud builds submit --tag us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest . + + - name: Deploy to Cloud Run + run: gcloud run deploy notely --image us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest --region us-central1 --allow-unauthenticated --project red-girder-468300-f2 --max-instances=4 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2be3d18b81..621c14581f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,6 @@ RUN apt-get update && apt-get install -y ca-certificates ADD notely /usr/bin/notely +ADD static /static + CMD ["notely"] From 2879c87d9932d415f190e7ca86071cba80c21a86 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Thu, 7 Aug 2025 16:25:23 -0700 Subject: [PATCH 22/29] added goose migrations to turso database into cd.yml --- .github/workflows/cd.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 13e91f53d1..cee1075a4d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -9,10 +9,16 @@ jobs: name: Deploy runs-on: ubuntu-latest + env: + DATABASE_URL: ${{ secrets.DATABASE_URL }} + steps: - name: Check out code uses: actions/checkout@v4 + - name: Set up Goose + run: go install github.com/pressly/goose/v3/cmd/goose@latest + - name: Set up Go uses: actions/setup-go@v5 with: @@ -35,5 +41,8 @@ jobs: - name: Build and push Docker image run: gcloud builds submit --tag us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest . + - name: Run Goose Migrations + run: goose sqlite3 "$DATABASE_URL" up -dir sql/schema + - name: Deploy to Cloud Run run: gcloud run deploy notely --image us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest --region us-central1 --allow-unauthenticated --project red-girder-468300-f2 --max-instances=4 \ No newline at end of file From f735b1c6991b54e438f7ed3537037317825c566c Mon Sep 17 00:00:00 2001 From: epenick123 Date: Thu, 7 Aug 2025 16:44:10 -0700 Subject: [PATCH 23/29] added goose migrations to turso database into cd.yml --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index cee1075a4d..b15e523344 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -42,7 +42,7 @@ jobs: run: gcloud builds submit --tag us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest . - name: Run Goose Migrations - run: goose sqlite3 "$DATABASE_URL" up -dir sql/schema + run: goose libsql "$DATABASE_URL" up -dir sql/schema - name: Deploy to Cloud Run run: gcloud run deploy notely --image us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest --region us-central1 --allow-unauthenticated --project red-girder-468300-f2 --max-instances=4 \ No newline at end of file From 523d15503b9541c6e0d34c0aeeb038ce2201bfc3 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Thu, 7 Aug 2025 17:03:49 -0700 Subject: [PATCH 24/29] fix cd.yml, reorder steps --- .github/workflows/cd.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b15e523344..37afc1094b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -16,18 +16,17 @@ jobs: - name: Check out code uses: actions/checkout@v4 - - name: Set up Goose - run: go install github.com/pressly/goose/v3/cmd/goose@latest - - name: Set up Go uses: actions/setup-go@v5 with: go-version: "1.23.0" + + - name: Set up Goose + run: go install github.com/pressly/goose/v3/cmd/goose@latest - name: Build app run: scripts/buildprod.sh - - id: 'auth' uses: 'google-github-actions/auth@v2' with: From 3162b8f68ffe229b1cd47348599345779a345a7c Mon Sep 17 00:00:00 2001 From: epenick123 Date: Thu, 7 Aug 2025 17:11:29 -0700 Subject: [PATCH 25/29] fix cd.yml, reorder steps --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 37afc1094b..6d63eba09e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -41,7 +41,7 @@ jobs: run: gcloud builds submit --tag us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest . - name: Run Goose Migrations - run: goose libsql "$DATABASE_URL" up -dir sql/schema + run: goose sqlite3 "$DATABASE_URL" up -dir sql/schema - name: Deploy to Cloud Run run: gcloud run deploy notely --image us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest --region us-central1 --allow-unauthenticated --project red-girder-468300-f2 --max-instances=4 \ No newline at end of file From 5ffc8bba1b3930b0cc950578f69d4313bcd576c9 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Thu, 7 Aug 2025 17:19:37 -0700 Subject: [PATCH 26/29] add database_url checks --- .github/workflows/cd.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 6d63eba09e..646cea0d98 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -40,6 +40,12 @@ jobs: - name: Build and push Docker image run: gcloud builds submit --tag us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest . + - name: Debug DATABASE_URL + run: echo "DATABASE_URL starts with ${DATABASE_URL:0:20}" + + - name: Check if DATABASE_URL is set + run: '[ -z "$DATABASE_URL" ] && echo "DATABASE_URL is empty" || echo "DATABASE_URL is set"' + - name: Run Goose Migrations run: goose sqlite3 "$DATABASE_URL" up -dir sql/schema From 82311b520f7c8c329e8b8065c3f1e84752486792 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Thu, 7 Aug 2025 17:31:20 -0700 Subject: [PATCH 27/29] fix cd.yml --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 646cea0d98..f7e01fee38 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -47,7 +47,7 @@ jobs: run: '[ -z "$DATABASE_URL" ] && echo "DATABASE_URL is empty" || echo "DATABASE_URL is set"' - name: Run Goose Migrations - run: goose sqlite3 "$DATABASE_URL" up -dir sql/schema + run: goose turso "$DATABASE_URL" up -dir sql/schema - name: Deploy to Cloud Run run: gcloud run deploy notely --image us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest --region us-central1 --allow-unauthenticated --project red-girder-468300-f2 --max-instances=4 \ No newline at end of file From 4b5a923c4ae284f58c37d867ef55412722a71024 Mon Sep 17 00:00:00 2001 From: epenick123 Date: Thu, 7 Aug 2025 18:07:00 -0700 Subject: [PATCH 28/29] fix cd.yml and goose migrate shell script --- scripts/migrateup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/migrateup.sh b/scripts/migrateup.sh index fe69c6fc7a..2428f842ac 100755 --- a/scripts/migrateup.sh +++ b/scripts/migrateup.sh @@ -4,5 +4,4 @@ if [ -f .env ]; then source .env fi -cd sql/schema -goose turso $DATABASE_URL up +goose turso "$DATABASE_URL" up -dir sql/schema From b69bf897ffd975592fee622d411e2d0ba3f70dae Mon Sep 17 00:00:00 2001 From: epenick123 Date: Thu, 7 Aug 2025 18:08:03 -0700 Subject: [PATCH 29/29] fix cd.yml and goose migrate shell script --- .github/workflows/cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f7e01fee38..4dbb089cc9 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -46,8 +46,8 @@ jobs: - name: Check if DATABASE_URL is set run: '[ -z "$DATABASE_URL" ] && echo "DATABASE_URL is empty" || echo "DATABASE_URL is set"' - - name: Run Goose Migrations - run: goose turso "$DATABASE_URL" up -dir sql/schema + - name: Migrate DB + run: ./scripts/migrateup.sh - name: Deploy to Cloud Run run: gcloud run deploy notely --image us-central1-docker.pkg.dev/red-girder-468300-f2/notely-ar-repo/notely:latest --region us-central1 --allow-unauthenticated --project red-girder-468300-f2 --max-instances=4 \ No newline at end of file