Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| abf975fadb | |||
| b96cc24527 | |||
| 0d1aaf940b | |||
| 2849b21d30 | |||
| 89205aa4e5 | |||
|
|
02220024be | ||
| bdd237b971 | |||
|
|
8d0d4ca27c | ||
| f3746731a5 | |||
|
|
2d62f64dfa | ||
| 837c5863fd | |||
| 7603f9395a | |||
| 222097af1c | |||
| 6ab3c33a1c | |||
| 03839c65a0 | |||
|
|
e1a36f3653 |
52
.github/workflows/cd.yml
vendored
Normal file
52
.github/workflows/cd.yml
vendored
Normal 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
|
||||
32
.github/workflows/ci.yml
vendored
32
.github/workflows/ci.yml
vendored
@@ -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 ./...)
|
||||
7
json.go
7
json.go
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
6
main.go
6
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.Second * 30,
|
||||
}
|
||||
|
||||
log.Printf("Serving on port: %s\n", port)
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user