Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8f90f1c
Create .env
Jeremy-J-Allen Feb 13, 2026
9b5d976
Update .env
Jeremy-J-Allen Feb 13, 2026
5130e9c
Update README.md
Jeremy-J-Allen Feb 15, 2026
186c73a
CI test workflow
Jeremy-J-Allen Feb 16, 2026
f93cf22
Add CI workflow
Jeremy-J-Allen Feb 16, 2026
e785556
Add .github README
Jeremy-J-Allen Feb 16, 2026
b32eee3
removed readme.md
Jeremy-J-Allen Feb 16, 2026
4cafb41
Updated CI test to pass
Jeremy-J-Allen Feb 17, 2026
3ba4118
Update auth.go
Jeremy-J-Allen Feb 18, 2026
bf867f7
Update ci.yml
Jeremy-J-Allen Feb 18, 2026
cd94558
Update auth.go
Jeremy-J-Allen Feb 18, 2026
a1cb0d6
Update auth.go
Jeremy-J-Allen Feb 18, 2026
03a5133
Add GetAPIKey unit tests
Jeremy-J-Allen Feb 18, 2026
f6a8b1e
Fix auth package and add tests
Jeremy-J-Allen Feb 18, 2026
b92862f
Show test coverage in CI
Jeremy-J-Allen Feb 18, 2026
741048c
Added CI status badge
Jeremy-J-Allen Feb 18, 2026
a0b0693
Run formatting check in parallel Style job
Jeremy-J-Allen Feb 21, 2026
05ab60e
test CI
Jeremy-J-Allen Feb 21, 2026
5c07d57
test CI
Jeremy-J-Allen Feb 21, 2026
8cb4c4d
updating
Jeremy-J-Allen Feb 21, 2026
60c8c0e
Format Go code (gofmt)
Jeremy-J-Allen Feb 21, 2026
3bb6b06
updated ci.yml
Jeremy-J-Allen Feb 21, 2026
8846d1c
Add staticcheck to Style job
Jeremy-J-Allen Feb 21, 2026
0d47067
Add unused function to trigger staticcheck
Jeremy-J-Allen Feb 21, 2026
184cca0
Remove unused function
Jeremy-J-Allen Feb 21, 2026
1ca1917
Fix formatting check to use gofmt
Jeremy-J-Allen Feb 21, 2026
bca033a
updated main.go
Jeremy-J-Allen Feb 21, 2026
c1c2b48
added gosec to ci.yml
Jeremy-J-Allen Feb 23, 2026
dbe42c9
added gosec to ci.yml
Jeremy-J-Allen Feb 23, 2026
469596b
added gosec to ci.yml
Jeremy-J-Allen Feb 23, 2026
a4ab1ef
added gosec to ci.yml
Jeremy-J-Allen Feb 23, 2026
180b409
Fix gosec step (ensure it runs)
Jeremy-J-Allen Feb 23, 2026
339e164
deleted the echo line
Jeremy-J-Allen Feb 24, 2026
779458d
added the echo line
Jeremy-J-Allen Feb 24, 2026
f276543
added the echo line
Jeremy-J-Allen Feb 24, 2026
83a83e3
added the echo line
Jeremy-J-Allen Feb 24, 2026
280b398
updated ci.yml
Jeremy-J-Allen Feb 24, 2026
81f3bdf
Updated json.go and main.go
Jeremy-J-Allen Feb 24, 2026
f75eb23
Updated json.go and main.go
Jeremy-J-Allen Feb 24, 2026
f042cfe
updated files
Jeremy-J-Allen Feb 24, 2026
1b15c20
updated files
Jeremy-J-Allen Feb 24, 2026
0eb5f51
updated ci.yml
Jeremy-J-Allen Feb 24, 2026
ce2b16a
fixed
Jeremy-J-Allen Feb 24, 2026
2b57718
updated ci.yml
Jeremy-J-Allen Feb 24, 2026
143960e
updated ci.yml
Jeremy-J-Allen Feb 24, 2026
21a7d8b
updated ci.yml
Jeremy-J-Allen Feb 24, 2026
fbf2c14
Add CD workflow
Jeremy-J-Allen Feb 25, 2026
f588c40
Authenticate to GCP and push image on main
Jeremy-J-Allen Mar 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PORT="8080"
40 changes: 40 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: cd

on:
push:
branches: [main]

permissions:
contents: read
id-token: write

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.22"

- name: Build production app
run: ./scripts/buildprod.sh

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WIF_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}

- name: Set up gcloud
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}

- name: Build and push image to Artifact Registry
run: |
gcloud builds submit --tag us-central1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/notely-ar-repo/notely:latest .
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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: Run unit tests
run: go test ./... -cover

- name: Install gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest

- name: Run gosec
run: gosec -exclude=G104,G114,G117,G705,G706 ./...

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 ./...)

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Run staticcheck
run: staticcheck ./...

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![CI Status](https://github.com/Jeremy-J-Allen/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).
Expand All @@ -21,3 +23,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!

Jeremy's version of Boot.dev's Notely app.
51 changes: 51 additions & 0 deletions ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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: Run unit tests
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

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 ./...)

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Run staticcheck
run: staticcheck ./...

4 changes: 3 additions & 1 deletion internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import (

var ErrNoAuthHeaderIncluded = errors.New("no authorization header included")

// GetAPIKey -
// GetAPIKey extracts an API key from the Authorization header.
// Expected format: "ApiKey <key>"
func GetAPIKey(headers http.Header) (string, error) {
authHeader := headers.Get("Authorization")
if authHeader == "" {
return "", ErrNoAuthHeaderIncluded
}

splitAuth := strings.Split(authHeader, " ")
if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" {
return "", errors.New("malformed authorization header")
Expand Down
20 changes: 20 additions & 0 deletions internal/auth/auth_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package auth

import (
"net/http"
"testing"
)

func TestGetAPIKey(t *testing.T) {
h := http.Header{}
h.Set("Authorization", "ApiKey testkey")

key, err := GetAPIKey(h)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}

if key != "testkey" {
t.Fatalf("expected testkey, got %s", key)
}
}
5 changes: 4 additions & 1 deletion json.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ 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("Critical error writing response: %s", err)
}
}
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
"time"

"github.com/go-chi/chi"
"github.com/go-chi/cors"
Expand Down Expand Up @@ -89,8 +90,9 @@ func main() {

router.Mount("/v1", v1Router)
srv := &http.Server{
Addr: ":" + port,
Handler: router,
Addr: ":" + port,
Handler: router,
ReadHeaderTimeout: time.Second * 5,
}

log.Printf("Serving on port: %s\n", port)
Expand Down
42 changes: 21 additions & 21 deletions vendor/github.com/go-chi/chi/chi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions vendor/github.com/go-chi/chi/context.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions vendor/github.com/go-chi/cors/cors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/google/uuid/dce.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/google/uuid/hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/google/uuid/node_js.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/google/uuid/node_net.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading