Skip to content

Commit

Permalink
update: add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu327 committed Dec 26, 2023
1 parent 9479922 commit 6a41811
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 19 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: ci

on:
push:
branches:
- "main"

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: zhu327/gemini-openai-proxy:latest
26 changes: 26 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
6 changes: 0 additions & 6 deletions api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ func ChatProxyHandler(c *gin.Context) {
go func() {
defer close(dataChan)

defer func() {
if r := recover(); r != nil {
log.Println("Recovered. Error:\n", r)
}
}()

respID := util.GetUUID()
created := time.Now().Unix()

Expand Down
15 changes: 2 additions & 13 deletions api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,8 @@ func Register(router *gin.Engine) {
// Configure CORS to allow all methods and all origins
config := cors.DefaultConfig()
config.AllowAllOrigins = true
config.AllowHeaders = []string{
"Accept",
"Authorization",
"Content-Type",
"Accept-Language",
"Content-Language",
"DPR",
"Downlink",
"Save-Data",
"Viewport-Width",
"Width",
"X-Requested-With",
}
config.AllowHeaders = []string{"*"}
config.AllowCredentials = true
config.OptionsResponseStatusCode = http.StatusOK
router.Use(cors.New(config))

Expand Down

0 comments on commit 6a41811

Please sign in to comment.