From b7d1944b3d7a604684c70927300ecbe4a113c3ea Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 13:51:38 +0000 Subject: [PATCH 01/23] Add author of fork to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b..062acf8857 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! + +Pedro's version of Boot.dev's Notely app. \ No newline at end of file From fd984358c24b22b2febdaf20f3280730ddc142e3 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 14:03:01 +0000 Subject: [PATCH 02/23] Add github actions workflow example --- .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..a54d8248d5 --- /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.25.1" + + - name: Force Failure + run: (exit 1) \ No newline at end of file From 525efb0ec9b571e19cbf96d144372f715eb0bd5e Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 14:07:28 +0000 Subject: [PATCH 03/23] Update CI workflow to verify Go installation instead of forcing failure --- .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 a54d8248d5..5135e33519 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.25.1" - - name: Force Failure - run: (exit 1) \ No newline at end of file + - name: Check Go is installed + run: go version \ No newline at end of file From 7dbf8facff42d22140c6a9b39d0663f265ce3e73 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:06:55 +0000 Subject: [PATCH 04/23] Add unit tests for GetAPIKey and update CI to run tests Code with bug to fail on purpose to test CI-CD --- .github/workflows/ci.yml | 2 +- internal/auth/auth.go | 6 ++--- internal/auth/auth_test.go | 55 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 internal/auth/auth_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5135e33519..b8d20064fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.25.1" - name: Check Go is installed - 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..3fa8598363 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -11,9 +11,9 @@ var ErrNoAuthHeaderIncluded = errors.New("no authorization header included") // GetAPIKey - func GetAPIKey(headers http.Header) (string, error) { authHeader := headers.Get("Authorization") - if authHeader == "" { - return "", ErrNoAuthHeaderIncluded - } + //if authHeader == "" { + // return "", ErrNoAuthHeaderIncluded + //} splitAuth := strings.Split(authHeader, " ") if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" { return "", errors.New("malformed authorization header") diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go new file mode 100644 index 0000000000..8cbd9b66ba --- /dev/null +++ b/internal/auth/auth_test.go @@ -0,0 +1,55 @@ +package auth + +import ( + "net/http" + "testing" +) + +func TestGetAPIKey(t *testing.T) { + tests := map[string]struct { + headers http.Header + want string + wantErr string // Use string to check error message content + }{ + "valid api key": { + headers: http.Header{"Authorization": []string{"ApiKey my-secret-token"}}, + want: "my-secret-token", + wantErr: "", + }, + "no auth header included": { + headers: http.Header{}, + want: "", + wantErr: ErrNoAuthHeaderIncluded.Error(), + }, + "malformed authorization header - wrong prefix": { + headers: http.Header{"Authorization": []string{"Bearer my-token"}}, + want: "", + wantErr: "malformed authorization header", + }, + "malformed authorization header - missing key": { + headers: http.Header{"Authorization": []string{"ApiKey"}}, + want: "", + wantErr: "malformed authorization header", + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + got, err := GetAPIKey(tc.headers) + + // Check the returned string value + if got != tc.want { + t.Errorf("expected: %v, got: %v", tc.want, got) + } + + // Check the error behavior + if err != nil { + if err.Error() != tc.wantErr { + t.Errorf("expected error: %v, got: %v", tc.wantErr, err.Error()) + } + } else if tc.wantErr != "" { + t.Errorf("expected error: %v, got: nil", tc.wantErr) + } + }) + } +} From 6b4a6b88be661d4baaa8e900c40de229b525829c Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:09:33 +0000 Subject: [PATCH 05/23] Fix GetAPIKey auth header handling and update CI job step name of test running --- .github/workflows/ci.yml | 2 +- internal/auth/auth.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8d20064fa..e1f9666941 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.25.1" - - name: Check Go is installed + - name: Run the tests run: go test ./... \ No newline at end of file diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 3fa8598363..f969aacf63 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -11,9 +11,9 @@ var ErrNoAuthHeaderIncluded = errors.New("no authorization header included") // GetAPIKey - func GetAPIKey(headers http.Header) (string, error) { authHeader := headers.Get("Authorization") - //if authHeader == "" { - // return "", ErrNoAuthHeaderIncluded - //} + if authHeader == "" { + return "", ErrNoAuthHeaderIncluded + } splitAuth := strings.Split(authHeader, " ") if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" { return "", errors.New("malformed authorization header") From 359b50993c2eecc80ca36a2e40bee333c6a97135 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:43:15 +0000 Subject: [PATCH 06/23] Update CI workflow to include test coverage flag --- .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 e1f9666941..a9311edb39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.25.1" - name: Run the tests - run: go test ./... \ No newline at end of file + run: go test ./... -cover \ No newline at end of file From 402726336c32fd2212e37e2192304b515f868b9d Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:47:43 +0000 Subject: [PATCH 07/23] Add CI status badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 062acf8857..4a9f96967b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # learn-cicd-starter (Notely) +![github actions status](https://github.com/pedroaguia8/Boot.dev-learn-cicd/actions/workflows/ci.yml/badge.svg) + This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). ## Local Development From a5c6281b8e08a065d04b22f94f9587f99609b03a Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 13:51:38 +0000 Subject: [PATCH 08/23] Add author of fork to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b..062acf8857 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! + +Pedro's version of Boot.dev's Notely app. \ No newline at end of file From 4c7e0aca98f863092c3011b9a7bb0d7af0cb8d4e Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 14:03:01 +0000 Subject: [PATCH 09/23] Add github actions workflow example --- .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..a54d8248d5 --- /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.25.1" + + - name: Force Failure + run: (exit 1) \ No newline at end of file From fa4d7205e078bf604d4d1a4f582173863fc1b2c4 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 14:07:28 +0000 Subject: [PATCH 10/23] Update CI workflow to verify Go installation instead of forcing failure --- .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 a54d8248d5..5135e33519 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.25.1" - - name: Force Failure - run: (exit 1) \ No newline at end of file + - name: Check Go is installed + run: go version \ No newline at end of file From c4646b067e8a47f95aca6547c88640baa2710ac0 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:06:55 +0000 Subject: [PATCH 11/23] Add unit tests for GetAPIKey and update CI to run tests Code with bug to fail on purpose to test CI-CD --- .github/workflows/ci.yml | 2 +- internal/auth/auth.go | 6 ++--- internal/auth/auth_test.go | 55 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 internal/auth/auth_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5135e33519..b8d20064fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.25.1" - name: Check Go is installed - 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..3fa8598363 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -11,9 +11,9 @@ var ErrNoAuthHeaderIncluded = errors.New("no authorization header included") // GetAPIKey - func GetAPIKey(headers http.Header) (string, error) { authHeader := headers.Get("Authorization") - if authHeader == "" { - return "", ErrNoAuthHeaderIncluded - } + //if authHeader == "" { + // return "", ErrNoAuthHeaderIncluded + //} splitAuth := strings.Split(authHeader, " ") if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" { return "", errors.New("malformed authorization header") diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go new file mode 100644 index 0000000000..8cbd9b66ba --- /dev/null +++ b/internal/auth/auth_test.go @@ -0,0 +1,55 @@ +package auth + +import ( + "net/http" + "testing" +) + +func TestGetAPIKey(t *testing.T) { + tests := map[string]struct { + headers http.Header + want string + wantErr string // Use string to check error message content + }{ + "valid api key": { + headers: http.Header{"Authorization": []string{"ApiKey my-secret-token"}}, + want: "my-secret-token", + wantErr: "", + }, + "no auth header included": { + headers: http.Header{}, + want: "", + wantErr: ErrNoAuthHeaderIncluded.Error(), + }, + "malformed authorization header - wrong prefix": { + headers: http.Header{"Authorization": []string{"Bearer my-token"}}, + want: "", + wantErr: "malformed authorization header", + }, + "malformed authorization header - missing key": { + headers: http.Header{"Authorization": []string{"ApiKey"}}, + want: "", + wantErr: "malformed authorization header", + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + got, err := GetAPIKey(tc.headers) + + // Check the returned string value + if got != tc.want { + t.Errorf("expected: %v, got: %v", tc.want, got) + } + + // Check the error behavior + if err != nil { + if err.Error() != tc.wantErr { + t.Errorf("expected error: %v, got: %v", tc.wantErr, err.Error()) + } + } else if tc.wantErr != "" { + t.Errorf("expected error: %v, got: nil", tc.wantErr) + } + }) + } +} From 88c2d984a5519b56260c65e53cd6ddafd6a9e593 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:09:33 +0000 Subject: [PATCH 12/23] Fix GetAPIKey auth header handling and update CI job step name of test running --- .github/workflows/ci.yml | 2 +- internal/auth/auth.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8d20064fa..e1f9666941 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.25.1" - - name: Check Go is installed + - name: Run the tests run: go test ./... \ No newline at end of file diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 3fa8598363..f969aacf63 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -11,9 +11,9 @@ var ErrNoAuthHeaderIncluded = errors.New("no authorization header included") // GetAPIKey - func GetAPIKey(headers http.Header) (string, error) { authHeader := headers.Get("Authorization") - //if authHeader == "" { - // return "", ErrNoAuthHeaderIncluded - //} + if authHeader == "" { + return "", ErrNoAuthHeaderIncluded + } splitAuth := strings.Split(authHeader, " ") if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" { return "", errors.New("malformed authorization header") From b8b5c5140845d0af7d7d11f240473f05f54878b1 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:43:15 +0000 Subject: [PATCH 13/23] Update CI workflow to include test coverage flag --- .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 e1f9666941..a9311edb39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.25.1" - name: Run the tests - run: go test ./... \ No newline at end of file + run: go test ./... -cover \ No newline at end of file From 25363556c39924691432e08e6230d5bdc5762d01 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:47:43 +0000 Subject: [PATCH 14/23] Add CI status badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 062acf8857..4a9f96967b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # learn-cicd-starter (Notely) +![github actions status](https://github.com/pedroaguia8/Boot.dev-learn-cicd/actions/workflows/ci.yml/badge.svg) + This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). ## Local Development From 5cd2d779d913d2d8afcec3e9e69dcabf87a8c9b4 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:01:07 +0000 Subject: [PATCH 15/23] Update CI workflow to include formatting check --- .github/workflows/ci.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9311edb39..bcc113aab2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,20 @@ jobs: go-version: "1.25.1" - name: Run the tests - 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.25.1" + + - name: Check formatting + run: test -z $(go fmt ./...) \ No newline at end of file From c93e8459ca101aaa72540a0467c84d38dde42788 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:18:49 +0000 Subject: [PATCH 16/23] Update CI workflow to include linting step and install staticcheck # Conflicts: # .github/workflows/ci.yml --- .github/workflows/ci.yml | 6 ++++++ main.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5212be1907..a674b9b2f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,5 +34,11 @@ jobs: with: go-version: "1.25.1" + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest + - name: Check formatting run: test -z $(go fmt ./...) + + - name: Check linting + run: staticcheck ./... \ No newline at end of file diff --git a/main.go b/main.go index 19d7366c5f..3690ae5b6e 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,11 @@ import ( _ "github.com/tursodatabase/libsql-client-go/libsql" ) +func unused() { + // this function does nothing + // and is called nowhere +} + type apiConfig struct { DB *database.Queries } From cda4642b2a6b759eea4e76867b3fc86ed1d9f1fc Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:23:18 +0000 Subject: [PATCH 17/23] Remove unused 'unused' function from main.go --- main.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/main.go b/main.go index 3690ae5b6e..19d7366c5f 100644 --- a/main.go +++ b/main.go @@ -17,11 +17,6 @@ import ( _ "github.com/tursodatabase/libsql-client-go/libsql" ) -func unused() { - // this function does nothing - // and is called nowhere -} - type apiConfig struct { DB *database.Queries } From f487ac3ccb24874b9e305e33719317c26aebe5dd Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:38:09 +0000 Subject: [PATCH 18/23] Update CI workflow to include gosec for security checks --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a674b9b2f9..7baaac62e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,9 +18,15 @@ jobs: with: go-version: "1.25.1" + - name: Install gosec + run: go install github.com/securego/gosec/v2/cmd/gosec@latest + - name: Run the tests run: go test ./... -cover + - name: Run the security check + run: gosec ./... + style: name: Style runs-on: ubuntu-latest From 8c88a1b88c100a4f4ab8aae3233d4a70671c4897 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:46:58 +0000 Subject: [PATCH 19/23] Handle response writer error and add read header timeout to HTTP server --- json.go | 7 ++++++- main.go | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/json.go b/json.go index 1e6e7985e1..d5c74cd492 100644 --- a/json.go +++ b/json.go @@ -30,5 +30,10 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) { return } w.WriteHeader(code) - w.Write(dat) + _, err = w.Write(dat) + if err != nil { + log.Printf("Error writing data to response: %s", err) + w.WriteHeader(500) + return + } } diff --git a/main.go b/main.go index 19d7366c5f..2323b0f234 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,8 +90,9 @@ func main() { router.Mount("/v1", v1Router) srv := &http.Server{ - Addr: ":" + port, - Handler: router, + Addr: ":" + port, + Handler: router, + ReadHeaderTimeout: time.Duration(5 * time.Second), } log.Printf("Serving on port: %s\n", port) From 0d817b89b51a7722ddcefd2fed8d600ae4de5658 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:22:23 +0000 Subject: [PATCH 20/23] Add CD workflow to deploy on push to main branch --- .github/workflows/cd.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 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..ef06e14df0 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,23 @@ +name: cd.yml +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.25.1" + + - name: Build app + run: ./scripts/buildprod.sh + + From a946da6ec2f31992da3ce9c67190dfda54523a54 Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 18:50:14 +0000 Subject: [PATCH 21/23] Update CD workflow to push build to Google Cloud Artifact Registry --- .github/workflows/cd.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ef06e14df0..1f23ef8e81 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -20,4 +20,10 @@ jobs: - name: Build app run: ./scripts/buildprod.sh + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v3' + + - name: 'Push build to Google Cloud Artifact Registry' + run: gcloud builds submit --tag us-central1-docker.pkg.dev/notely-478717/notely-ar-repo/notely:latest . + From 7bec6735a3bea7508273979cc7e4bbd348c3080f Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 18:50:14 +0000 Subject: [PATCH 22/23] Update CD workflow to push build to Google Cloud Artifact Registry --- .github/workflows/cd.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ef06e14df0..1f23ef8e81 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -20,4 +20,10 @@ jobs: - name: Build app run: ./scripts/buildprod.sh + - name: 'Set up Cloud SDK' + uses: 'google-github-actions/setup-gcloud@v3' + + - name: 'Push build to Google Cloud Artifact Registry' + run: gcloud builds submit --tag us-central1-docker.pkg.dev/notely-478717/notely-ar-repo/notely:latest . + From e02e25eb2df9dc1b6924ca05b5daad44142be36b Mon Sep 17 00:00:00 2001 From: pedroaguia8 <24630163+pedroaguia8@users.noreply.github.com> Date: Wed, 19 Nov 2025 18:55:18 +0000 Subject: [PATCH 23/23] Add authentication step to CD workflow using GCP credentials --- .github/workflows/cd.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1f23ef8e81..68f3d552fb 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -20,6 +20,11 @@ jobs: - name: Build app 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@v3'