Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
099cccc
My first Pull Request
VeronicaLobos Sep 15, 2025
de819f0
Merge branch 'addtests' of github.com:VeronicaLobos/learn-cicd-starte…
VeronicaLobos Sep 15, 2025
b61942d
Adding Workflow
VeronicaLobos Sep 15, 2025
b98f579
Update CI job to check go version
VeronicaLobos Sep 15, 2025
1dbedab
New workflow with broken code for testing auth.go
VeronicaLobos Sep 15, 2025
61c7507
New workflow with fixed code for testing auth.go
VeronicaLobos Sep 15, 2025
39f93b3
Checking code coverage
VeronicaLobos Sep 16, 2025
7c48226
Checking code coverage 2nd try
VeronicaLobos Sep 16, 2025
5ef7149
Add README Badge for Tests
VeronicaLobos Sep 16, 2025
10fbb80
Merge pull request #1 from VeronicaLobos/addtests
VeronicaLobos Sep 16, 2025
859be5b
Add README Badge for Tests fix broken image
VeronicaLobos Sep 16, 2025
b9cb90d
Add README Badge for Tests fix broken badge
VeronicaLobos Sep 16, 2025
30a629b
Add README Badge for Tests fix broken badge
VeronicaLobos Sep 16, 2025
08eb1d2
New ci workflowjob: Style implemented
VeronicaLobos Sep 16, 2025
fbd4436
Revert "New ci workflowjob: Style implemented"
VeronicaLobos Sep 16, 2025
2a90f6a
New ci workflowjob: Style implemented
VeronicaLobos Sep 16, 2025
3f60005
Revert "New ci workflowjob: Style implemented"
VeronicaLobos Sep 16, 2025
1820afc
New ci workflowjob: Style implemented in new branch
VeronicaLobos Sep 16, 2025
526729c
style: Format Go files
VeronicaLobos Sep 16, 2025
e805a10
Merge pull request #2 from VeronicaLobos/style
VeronicaLobos Sep 16, 2025
077d9bd
New ci workflowjob: Style implemented in new branch, second try
VeronicaLobos Sep 16, 2025
00d4a67
New ci workflowjob: Style implemented in new branch, third try
VeronicaLobos Sep 16, 2025
2df0715
Install linter for runner
VeronicaLobos Sep 16, 2025
e1e8715
Install linter for runner with unused function
VeronicaLobos Sep 16, 2025
6b562e2
Install linter for runner with unused function removed
VeronicaLobos Sep 16, 2025
1fa3416
Merge pull request #3 from VeronicaLobos/style
VeronicaLobos Sep 16, 2025
2627150
Merge pull request #4 from VeronicaLobos/addtests
VeronicaLobos Sep 16, 2025
e840eb9
Install and run gosec in workflow
VeronicaLobos Sep 16, 2025
a3232a5
Fix gosec workflow
VeronicaLobos Sep 16, 2025
ddbb086
Fixed security Issues found by gosec
VeronicaLobos Sep 16, 2025
a378809
New CD Workflow: Build Docker image
VeronicaLobos Sep 16, 2025
f9f6a4f
Merge pull request #6 from VeronicaLobos/builddocker
VeronicaLobos Sep 16, 2025
90ab6d9
Merge branch 'main' into gosec
VeronicaLobos Sep 17, 2025
f36d0d8
Merge pull request #5 from VeronicaLobos/gosec
VeronicaLobos Sep 17, 2025
1300b40
Fresh clone, implementing correct deploy workflow
VeronicaLobos Sep 17, 2025
67b7e22
fix(cd): Use correct Docker Hub username in image tag
VeronicaLobos Sep 17, 2025
f31f8b2
Add GitHub Actions workflow for CI/CD: Set up for Google Cloud
VeronicaLobos Sep 18, 2025
1fec5aa
Fixing ppipeline, latest build not listed in artifact registry GCP
VeronicaLobos Sep 18, 2025
4ccb381
Fixing ppipeline, latest build not listed in artifact registry GCP 2
VeronicaLobos Sep 18, 2025
d17c4ac
Updated workflow to automatically deploy changes to the app when push…
VeronicaLobos Sep 19, 2025
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
46 changes: 46 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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 Go application for Linux
run: GOOS=linux go build -o notely .

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push the Docker image
run: |
docker build -t veronicalobos87/notely:latest .
docker push veronicalobos87/notely:latest

# Authenticate to Google Cloud
- name: Authenticate to Google Cloud
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'

# Deploy to Cloud Run
- name: Deploy to Cloud Run
run: >-
gcloud run deploy notely
--image docker.io/veronicalobos87/notely:latest
--region us-central1
--allow-unauthenticated
--project ${{ secrets.GCP_PROJECT_ID }}
--max-instances=4
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![CI Tests](https://github.com/VeronicaLobos/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!

VeronicaLobos's version of Boot.dev's Notely app.
Binary file added auth.test
Binary file not shown.
70 changes: 70 additions & 0 deletions internal/auth/auth_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package auth

import (
"errors"
"net/http"
"testing"
)

func TestGetAPIKey(t *testing.T) {
// A table of test cases, each with a name, input, and expected output.
cases := []struct {
name string
inputHeader http.Header
expectedAPIKey string
expectedErr error
}{
{
name: "Valid Auth Header",
inputHeader: http.Header{
"Authorization": []string{"ApiKey my-secret-api-key"},
},
expectedAPIKey: "my-secret-api-key",
expectedErr: nil,
},
{
name: "No Auth Header",
inputHeader: http.Header{},
expectedAPIKey: "",
expectedErr: ErrNoAuthHeaderIncluded,
},
{
name: "Malformed Header - Wrong Prefix",
inputHeader: http.Header{
"Authorization": []string{"Bearer my-secret-api-key"},
},
expectedAPIKey: "",
expectedErr: errors.New("malformed authorization header"),
},
{
name: "Malformed Header - No Value",
inputHeader: http.Header{
"Authorization": []string{"ApiKey"},
},
expectedAPIKey: "",
expectedErr: errors.New("malformed authorization header"),
},
}

// Loop through all the test cases.
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
// Call the function we are testing.
apiKey, err := GetAPIKey(tc.inputHeader)

// Check if the returned API key is what we expected.
if apiKey != tc.expectedAPIKey {
t.Errorf("expected api key '%s', got '%s'", tc.expectedAPIKey, apiKey)
}

// Check if the returned error is what we expected.
if tc.expectedErr != nil {
if err == nil || err.Error() != tc.expectedErr.Error() {
t.Errorf("expected error '%v', got '%v'", tc.expectedErr, err)
}
} else if err != nil {
t.Errorf("expected no error, got '%v'", err)
}
})
}
}
4 changes: 3 additions & 1 deletion json.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
return
}
w.WriteHeader(code)
w.Write(dat)
if _, err := w.Write(dat); err != nil {
log.Printf("Error writing response: %v", err)
}
}
7 changes: 5 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 @@ -88,9 +89,11 @@ func main() {
v1Router.Get("/healthz", handlerReadiness)

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

log.Printf("Serving on port: %s\n", port)
Expand Down
Empty file added requirements.txt
Empty file.
2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</head>

<body class="section">
<h1>Notely</h1>
<h1>Welcome to Notely</h1>

<div id="userCreationContainer" class="section">
<input id="nameField" type="text" placeholder="Enter your name">
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.

17 changes: 8 additions & 9 deletions vendor/github.com/google/uuid/null.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/google/uuid/version4.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/nhooyr.io/websocket/accept.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/nhooyr.io/websocket/close_notjs.go

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

Loading