16 Commits

Author SHA1 Message Date
abf975fadb automatic migrations
Some checks failed
cd / Deploy (push) Failing after 6m59s
2025-03-16 15:21:49 +02:00
b96cc24527 fix deployment script 2025-03-16 15:07:53 +02:00
0d1aaf940b automatic deployment? 2025-03-16 15:05:54 +02:00
2849b21d30 rearrange steps? 2025-03-16 14:52:28 +02:00
89205aa4e5 cd test 2025-03-16 14:49:53 +02:00
RDarius
02220024be Merge pull request #4 from rdarius/cd-test-1
image push test
2025-03-16 14:44:01 +02:00
bdd237b971 image push test 2025-03-16 14:41:49 +02:00
RDarius
8d0d4ca27c Merge pull request #3 from rdarius/cd-test-1
cd test
2025-03-16 14:06:55 +02:00
f3746731a5 cd test 2025-03-16 14:04:55 +02:00
RDarius
2d62f64dfa Merge pull request #2 from rdarius/styles
style check
2025-03-16 13:53:52 +02:00
837c5863fd fix security issues 2025-03-16 13:47:40 +02:00
7603f9395a security checks 2025-03-16 13:42:59 +02:00
222097af1c remove unused function 2025-03-16 13:38:14 +02:00
6ab3c33a1c linting (with failing code) 2025-03-16 13:36:53 +02:00
03839c65a0 style check 2025-03-16 13:31:55 +02:00
RDarius
e1a36f3653 Merge pull request #1 from rdarius/addtests
Readme update
2025-03-16 13:24:16 +02:00
5 changed files with 94 additions and 5 deletions

52
.github/workflows/cd.yml vendored Normal file
View File

@@ -0,0 +1,52 @@
name: cd
on:
push:
branches: [main]
jobs:
deploy:
permissions:
contents: 'read'
id-token: 'write'
name: Deploy
runs-on: ubuntu-latest
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
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
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'
- name: 'Use gcloud CLI'
run: 'gcloud info'
- name: Push to Google
run: gcloud builds submit --tag us-central1-docker.pkg.dev/notely-453912/notely-ar-repo/notely:latest .
- name: Install Goose
run: go install github.com/pressly/goose/v3/cmd/goose@latest
- name: Run migrations
run: scripts/migrateup.sh
- name: Deploy to Cloud Run
run: gcloud run deploy notely --image us-central1-docker.pkg.dev/notely-453912/notely-ar-repo/notely:latest --region us-central1 --allow-unauthenticated --project notely-453912 --max-instances=4

View File

@@ -18,5 +18,35 @@ jobs:
with:
go-version: "1.23.0"
- name: Install gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: Tests
run: go test ./... -cover
run: go test ./... -cover
- name: Security Checks
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.23.0"
- name: Install staticcheck
uses: dominikh/staticcheck-action@v1
with:
version: "latest"
- name: Style
run: test -z $(go fmt ./...)
- name: Linting
run: test -z $(go fmt ./...)

View File

@@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
@@ -30,5 +31,9 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
return
}
w.WriteHeader(code)
w.Write(dat)
_, err = w.Write(dat)
if err != nil {
fmt.Printf("Error wiring response: %s", err.Error())
return
}
}

View File

@@ -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.Second * 30,
}
log.Printf("Serving on port: %s\n", port)

View File

@@ -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">