Skip to content

Commit

Permalink
fix pipeline saas
Browse files Browse the repository at this point in the history
  • Loading branch information
djengua committed Dec 19, 2023
1 parent 3271a03 commit 7c33034
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,19 @@ jobs:
with:
name: api
path: artifacts
deploy-function:
name: Deploy FaaS
deploy-paas:
name: Deploy PaaS
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
steps:
- name: Check out the code into the Go module directory
uses: actions/checkout@v4
- name: Check out cod einto the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Deploy function
- name: Deploy App
id: deploy
uses: google-github-actions/deploy-cloud-functions@main
uses: google-github-actions/deploy-appengin@main
with:
name: translate
entry_point: Translate
runtime: go12
credentials_json: ${{ secrets.gcp_credentials }}
creedentials: ${{ secrets.gcp_credentials }}
- id: test
run: curl "${{ steps.deploy.outputs.url }}/hello"
15 changes: 15 additions & 0 deletions app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
runtime: go12
main: ./cmd
liveness_check:
path: "/health"
check_interval_sec: 30
timeout_sec: 4
failure_threshold: 2
success_threshold: 2
readiness_check:
path: "/health"
check_interval_sec: 5
timeout_sec: 4
failure_threshold: 2
success_threshold: 2
app_start_timeout_sec: 300
15 changes: 15 additions & 0 deletions handlers/healt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package handlers

import (
"encoding/json"
"net/http"
)

func HealthCheck(w http.ResponseWriter, r *http.Request) {
enc := json.NewEncoder(w)
w.Header().Set("Content-Type", "application/json; charset=utf-8")
resp := map[string]string{"status": "up"}
if err := enc.Encode(resp); err != nil {
panic("unable to encode response")
}
}
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"log"
"net/http"

"github.com/djengua/rifa-api/faas"
"github.com/djengua/rifa-api/handlers"
)

func main() {
addr := ":8080"
mux := http.NewServeMux()

mux.HandleFunc("/hello", faas.Translate)
mux.HandleFunc("/hello", handlers.TranslateHandler)
mux.HandleFunc("/health", handlers.HealthCheck)
log.Printf("listening on %s\n", addr)
log.Fatal(http.ListenAndServe(addr, mux))
}
Expand Down

0 comments on commit 7c33034

Please sign in to comment.