From b3d981a6c61be7642927981217ceddb3e1021690 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 17 Oct 2024 19:10:20 +0800 Subject: [PATCH 01/61] =?UTF-8?q?=E5=A2=9E=E5=8A=A0action=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/demo.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .gitea/workflows/demo.yaml diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml new file mode 100644 index 0000000..394c807 --- /dev/null +++ b/.gitea/workflows/demo.yaml @@ -0,0 +1,19 @@ +name: Gitea Actions Demo +run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 +on: [push] + +jobs: + Explore-Gitea-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" + - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." + - name: Check out repository code + uses: actions/checkout@v4 + - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository + run: | + ls ${{ gitea.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file From 3d4755e4625977e7812195eae720f4a8e204fc88 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 17 Oct 2024 19:21:51 +0800 Subject: [PATCH 02/61] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/contents.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/contents.go b/controllers/contents.go index f1c7523..5a01dc8 100644 --- a/controllers/contents.go +++ b/controllers/contents.go @@ -16,7 +16,7 @@ func CreateContentHandler(ctx *gin.Context) { } if err := models.DB.Create(&content).Error; err != nil { - ctx.JSON(500, gin.H{"error": "Failed to create content"}) + ctx.JSON(500, gin.H{"error": "增加失败"}) return } From fb2415a7bdde8b869ca98d0464ef653b3f810977 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 17 Oct 2024 19:56:08 +0800 Subject: [PATCH 03/61] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=A1=A8=E6=83=85?= =?UTF-8?q?=E5=8C=85=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/demo.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index 394c807..6782a59 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -6,14 +6,14 @@ jobs: Explore-Gitea-Actions: runs-on: ubuntu-latest steps: - - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." + - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event." + - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!" + - run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - name: Check out repository code uses: actions/checkout@v4 - - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - run: echo "The ${{ gitea.repository }} repository has been cloned to the runner." + - run: echo "The workflow is now ready to test your code on the runner." - name: List files in the repository run: | ls ${{ gitea.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file + - run: echo "This job's status is ${{ job.status }}." \ No newline at end of file From 752e43a934b07cda61f50ba293953fc14654e850 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 17 Oct 2024 20:00:21 +0800 Subject: [PATCH 04/61] =?UTF-8?q?=E5=88=9A=E6=89=8D=E5=B0=91=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=B8=80=E4=B8=AA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/demo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index 6782a59..d59bcbc 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -1,5 +1,5 @@ name: Gitea Actions Demo -run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 +run-name: ${{ gitea.actor }} is testing out Gitea Actions on: [push] jobs: From ea07ca2ab18b0c1b5cb63beb25d70bcfce096aff Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 17 Oct 2024 20:08:31 +0800 Subject: [PATCH 05/61] test --- controllers/contents.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/contents.go b/controllers/contents.go index 5a01dc8..5340326 100644 --- a/controllers/contents.go +++ b/controllers/contents.go @@ -16,7 +16,7 @@ func CreateContentHandler(ctx *gin.Context) { } if err := models.DB.Create(&content).Error; err != nil { - ctx.JSON(500, gin.H{"error": "增加失败"}) + ctx.JSON(500, gin.H{"error": "增加内容失败"}) return } From 7af4061640c61e82d82a1d8042200f04052b7ef0 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 17 Oct 2024 23:46:45 +0800 Subject: [PATCH 06/61] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=AE=B9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/demo.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index d59bcbc..38686ac 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -16,4 +16,16 @@ jobs: - name: List files in the repository run: | ls ${{ gitea.workspace }} - - run: echo "This job's status is ${{ job.status }}." \ No newline at end of file + - run: echo "This job's status is ${{ job.status }}." + container-job: + runs-on: ubuntu-latest + container: golang:latest + env: + GO111MODULE: on + GOPROXY: https://goproxy.cn,direct + ports: + - 80:80 + volumes: + - /data:/data + options: + entrypoint: /bin/sh From 0a1ee3fdf42a8d9b3837aa7d3a7efa1e777cce4c Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 17 Oct 2024 23:56:50 +0800 Subject: [PATCH 07/61] container test --- .gitea/workflows/demo.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index 38686ac..c552e8a 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -29,3 +29,6 @@ jobs: - /data:/data options: entrypoint: /bin/sh + steps: + - name: Check for dockerenv file + run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv) From 045fe99f823c36ea4df918ca7105047c27f99e31 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 18 Oct 2024 00:00:36 +0800 Subject: [PATCH 08/61] test1 --- .gitea/workflows/demo.yaml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index c552e8a..b2b6b8f 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -17,18 +17,4 @@ jobs: run: | ls ${{ gitea.workspace }} - run: echo "This job's status is ${{ job.status }}." - container-job: - runs-on: ubuntu-latest - container: golang:latest - env: - GO111MODULE: on - GOPROXY: https://goproxy.cn,direct - ports: - - 80:80 - volumes: - - /data:/data - options: - entrypoint: /bin/sh - steps: - - name: Check for dockerenv file - run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv) + From 2673472a1ebebf0809becae078585f50193af9b9 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 18 Oct 2024 00:04:15 +0800 Subject: [PATCH 09/61] ports --- .gitea/workflows/demo.yaml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index b2b6b8f..94c4020 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -17,4 +17,18 @@ jobs: run: | ls ${{ gitea.workspace }} - run: echo "This job's status is ${{ job.status }}." - + container-job: + runs-on: ubuntu-latest + container: golang:latest + env: + GO111MODULE: on + GOPROXY: https://goproxy.cn,direct + ports: + - 80 + volumes: + - /data:/data + options: + entrypoint: /bin/sh + steps: + - name: Check for dockerenv file + run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv) From a2cf568e06b1cbb6bde62a44845db06806a23b5a Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 18 Oct 2024 00:06:27 +0800 Subject: [PATCH 10/61] image --- .gitea/workflows/demo.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index 94c4020..cbf50dd 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -19,7 +19,8 @@ jobs: - run: echo "This job's status is ${{ job.status }}." container-job: runs-on: ubuntu-latest - container: golang:latest + container: + image: golang:latest env: GO111MODULE: on GOPROXY: https://goproxy.cn,direct From 2df58bc74eb4c1b8b0bedb57f4cb99e846d6f55e Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 18 Oct 2024 00:11:26 +0800 Subject: [PATCH 11/61] tttttt --- .gitea/workflows/demo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index cbf50dd..30f134d 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -4,7 +4,7 @@ on: [push] jobs: Explore-Gitea-Actions: - runs-on: ubuntu-latest + runs-on: ubuntu-lates111t steps: - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event." - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!" From 143934384b266a9bcede8a75ba36cb266edd8e51 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 18 Oct 2024 00:16:25 +0800 Subject: [PATCH 12/61] test container --- .gitea/workflows/demo.yaml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index 30f134d..b242ad3 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -3,20 +3,6 @@ run-name: ${{ gitea.actor }} is testing out Gitea Actions on: [push] jobs: - Explore-Gitea-Actions: - runs-on: ubuntu-lates111t - steps: - - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: Check out repository code - uses: actions/checkout@v4 - - run: echo "The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ gitea.workspace }} - - run: echo "This job's status is ${{ job.status }}." container-job: runs-on: ubuntu-latest container: From 55cfff92219fb3b9d018d08599c9af982bcfd343 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 18 Oct 2024 00:24:39 +0800 Subject: [PATCH 13/61] test --- .gitea/workflows/demo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index b242ad3..985a4a3 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -17,5 +17,5 @@ jobs: options: entrypoint: /bin/sh steps: - - name: Check for dockerenv file + - name: Check for dockerenv file1 run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv) From d9e9fa510a9a8ecbacb3ccb41bdac7a0ce09a360 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Tue, 22 Oct 2024 19:22:12 +0800 Subject: [PATCH 14/61] test --- .gitea/workflows/demo.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index 985a4a3..e751859 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -4,6 +4,7 @@ on: [push] jobs: container-job: + name: my first job runs-on: ubuntu-latest container: image: golang:latest @@ -11,11 +12,9 @@ jobs: GO111MODULE: on GOPROXY: https://goproxy.cn,direct ports: - - 80 + - 8080 volumes: - /data:/data - options: - entrypoint: /bin/sh steps: - name: Check for dockerenv file1 run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv) From 3286dd19d6c0152b5ac5aee20af1791e3d77b851 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Wed, 23 Oct 2024 18:20:55 +0800 Subject: [PATCH 15/61] test --- .gitea/Dockerfile | 15 +++++++++++++++ .gitea/workflows/demo.yaml | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 .gitea/Dockerfile diff --git a/.gitea/Dockerfile b/.gitea/Dockerfile new file mode 100644 index 0000000..07391b3 --- /dev/null +++ b/.gitea/Dockerfile @@ -0,0 +1,15 @@ +FROM golang:alpine AS builder + +WORKDIR /build + +ADD go.mod . +COPY . . +RUN go build + + +FROM alpine + +WORKDIR /build +COPY --from=builder /build/hello /build/hello + +CMD ["./go_blog"] \ No newline at end of file diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index e751859..f3f1f6a 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -15,6 +15,9 @@ jobs: - 8080 volumes: - /data:/data + options: + entrypoint: /data/ + steps: - name: Check for dockerenv file1 run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv) From c828763723932abdc0b3f002d20c6087ec28f582 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 24 Oct 2024 10:29:15 +0800 Subject: [PATCH 16/61] go --- .gitea/workflows/go.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .gitea/workflows/go.yaml diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml new file mode 100644 index 0000000..ca3644c --- /dev/null +++ b/.gitea/workflows/go.yaml @@ -0,0 +1,19 @@ +name: Go +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.x' + - name: Install dependencies + run: go get . + - name: Build + run: go build -v ./... + - name: Test with the Go CLI + run: go test \ No newline at end of file From 999e5387712372fa869e21e201e626879d8751d9 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 24 Oct 2024 11:25:00 +0800 Subject: [PATCH 17/61] go build --- .gitea/workflows/go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index ca3644c..ee7b8d0 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -1,4 +1,4 @@ -name: Go +name: Go build on: [push] jobs: From 254eee4914591bbbcc21a3ca634ea3ffd8464841 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 24 Oct 2024 11:26:36 +0800 Subject: [PATCH 18/61] test go --- .gitea/workflows/demo.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index f3f1f6a..b56c578 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -15,8 +15,6 @@ jobs: - 8080 volumes: - /data:/data - options: - entrypoint: /data/ steps: - name: Check for dockerenv file1 From 75f4c2266c02a5260c8dfd18ab2e6e30ff4a75ae Mon Sep 17 00:00:00 2001 From: zhangchao Date: Mon, 28 Oct 2024 16:15:45 +0800 Subject: [PATCH 19/61] test go --- .gitea/workflows/go.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index ee7b8d0..448223d 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -11,8 +11,6 @@ jobs: uses: actions/setup-go@v5 with: go-version: '1.21.x' - - name: Install dependencies - run: go get . - name: Build run: go build -v ./... - name: Test with the Go CLI From 1020ad5997e09a8c4157219af127d7cd8905219a Mon Sep 17 00:00:00 2001 From: zhangchao Date: Wed, 30 Oct 2024 18:41:42 +0800 Subject: [PATCH 20/61] 20241030 --- .gitea/workflows/go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 448223d..8dbe4e6 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -12,6 +12,6 @@ jobs: with: go-version: '1.21.x' - name: Build - run: go build -v ./... + run: go build -v ./.. - name: Test with the Go CLI run: go test \ No newline at end of file From a05f78b07eb4826d5016ba9c68744f7abc7d47b5 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Wed, 30 Oct 2024 18:47:13 +0800 Subject: [PATCH 21/61] change go version 122 --- .gitea/workflows/go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 8dbe4e6..08a59f7 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -10,7 +10,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.21.x' + go-version: '1.22.0' - name: Build run: go build -v ./.. - name: Test with the Go CLI From de3dbd35161a8cf0c615498a23b4ba2160d47dae Mon Sep 17 00:00:00 2001 From: zhangchao Date: Wed, 30 Oct 2024 18:53:11 +0800 Subject: [PATCH 22/61] delete build ... --- .gitea/workflows/go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 08a59f7..6cc4a61 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -12,6 +12,6 @@ jobs: with: go-version: '1.22.0' - name: Build - run: go build -v ./.. + run: go build -v - name: Test with the Go CLI run: go test \ No newline at end of file From 211c17a13140d5c77cd6af442de69345d491622c Mon Sep 17 00:00:00 2001 From: zhangchao Date: Wed, 30 Oct 2024 19:00:15 +0800 Subject: [PATCH 23/61] change 1.22.x --- .gitea/workflows/go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 6cc4a61..c7b254f 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -10,7 +10,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.22.0' + go-version: '1.22.x' - name: Build run: go build -v - name: Test with the Go CLI From 2d4c3e79f6a54a71efd3cde90ab21d36e58da979 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Wed, 30 Oct 2024 19:14:32 +0800 Subject: [PATCH 24/61] go version 1.21.5 --- .gitea/workflows/go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index c7b254f..31504aa 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -10,7 +10,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.22.x' + go-version: '1.21.5' - name: Build run: go build -v - name: Test with the Go CLI From e7d3e66b47c31eef4e8dbdc00fc08d937452c8c1 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Wed, 30 Oct 2024 19:28:24 +0800 Subject: [PATCH 25/61] go version 1.21.13 --- .gitea/workflows/go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 31504aa..b9bcec9 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -10,7 +10,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.21.5' + go-version: '1.21.13' - name: Build run: go build -v - name: Test with the Go CLI From befcc7acf9cdd498684b021c181e17aae68a01f8 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Wed, 30 Oct 2024 19:38:15 +0800 Subject: [PATCH 26/61] use container golang:latest --- .gitea/workflows/go.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index b9bcec9..4255b16 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -3,15 +3,18 @@ on: [push] jobs: build: + name: Build and test runs-on: ubuntu-latest - + container: + image: golang:latest + env: + GO111MODULE: on + GOPROXY: https://goproxy.cn,direct + ports: + - 8080 steps: - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: '1.21.13' - name: Build run: go build -v - name: Test with the Go CLI - run: go test \ No newline at end of file + run: go test From 20a18f81ced674041c2c672211931cf52cc32039 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Wed, 30 Oct 2024 22:18:59 +0800 Subject: [PATCH 27/61] change ubuntu --- .gitea/workflows/go.yaml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 4255b16..c05dc11 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -5,15 +5,13 @@ jobs: build: name: Build and test runs-on: ubuntu-latest - container: - image: golang:latest - env: - GO111MODULE: on - GOPROXY: https://goproxy.cn,direct - ports: - - 8080 + steps: - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.x' - name: Build run: go build -v - name: Test with the Go CLI From ffd56e833c17881dc1e19bde9ac426a81f351682 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Wed, 30 Oct 2024 23:06:35 +0800 Subject: [PATCH 28/61] build with golang container --- .gitea/workflows/go.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index c05dc11..1fd846f 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -13,6 +13,13 @@ jobs: with: go-version: '1.21.x' - name: Build + container: + image: golang:latest + env: + GO111MODULE: on + GOPROXY: https://goproxy.cn,direct + ports: + - 8080 run: go build -v - name: Test with the Go CLI - run: go test + run: go test \ No newline at end of file From 770482d05d0b0ebf3f0651d8baa05d861c310a81 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 02:52:50 +0800 Subject: [PATCH 29/61] remove set go --- .gitea/workflows/go.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 1fd846f..7b952bf 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -8,10 +8,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: '1.21.x' + - name: Build container: image: golang:latest From 9a795f4c2c534665d1ac1f50fcf663a5def6a919 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 08:55:31 +0800 Subject: [PATCH 30/61] container up --- .gitea/workflows/go.yaml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 7b952bf..1e3b7ad 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -6,17 +6,18 @@ jobs: name: Build and test runs-on: ubuntu-latest + container: + image: golang:latest + env: + GO111MODULE: on + GOPROXY: https://goproxy.cn,direct + ports: + - 8080 steps: - uses: actions/checkout@v4 - name: Build - container: - image: golang:latest - env: - GO111MODULE: on - GOPROXY: https://goproxy.cn,direct - ports: - - 8080 + run: go build -v - name: Test with the Go CLI run: go test \ No newline at end of file From c096a94351c3b7a00afa6b6da8481bf22cfb4923 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 18:47:19 +0800 Subject: [PATCH 31/61] test golang container --- .gitea/workflows/go.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 1e3b7ad..4fe00d3 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -13,6 +13,7 @@ jobs: GOPROXY: https://goproxy.cn,direct ports: - 8080 + steps: - uses: actions/checkout@v4 From 4b7192cb59dd40432f39e324fa87cb96b67a33c5 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 19:10:55 +0800 Subject: [PATCH 32/61] add dockerfile --- .gitea/workflows/go.yaml | 45 ++++++++++++++++++++++++++++------------ Dokerfile.yaml | 26 +++++++++++++++++++++++ 2 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 Dokerfile.yaml diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 4fe00d3..85173ab 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -1,24 +1,43 @@ name: Go build -on: [push] +on: + push: + branches: [ master ] jobs: build: name: Build and test runs-on: ubuntu-latest - - container: - image: golang:latest - env: - GO111MODULE: on - GOPROXY: https://goproxy.cn,direct - ports: - - 8080 steps: + - name: Checkout - uses: actions/checkout@v4 - - name: Build - - run: go build -v + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21 + + - name: Build project + run: | + go build -v ./... - name: Test with the Go CLI - run: go test \ No newline at end of file + run: go test + + docker: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build Docker image + run: | + docker build -t your-image-name:latest -f ./Dockerfile . + + - name: Run Docker container + run: | + docker run -d -p 8080:8080 your-image-name:latest \ No newline at end of file diff --git a/Dokerfile.yaml b/Dokerfile.yaml new file mode 100644 index 0000000..255f378 --- /dev/null +++ b/Dokerfile.yaml @@ -0,0 +1,26 @@ +# 使用官方的 Go 运行时作为基础镜像 +FROM golang:1.18-alpine AS builder + +# 设置工作目录 +WORKDIR /app + +# 将当前目录下的所有文件复制到工作目录中 +COPY . . + +# 构建可执行文件 +RUN CGO_ENABLED=0 GOOS=linux go build -v -o app . + +# 使用一个更小的基础镜像来减小最终镜像的大小 +FROM alpine:latest + +# 设置工作目录 +WORKDIR /root/ + +# 从构建阶段复制可执行文件 +COPY --from=builder /app/app . + +# 暴露端口 +EXPOSE 8080 + +# 运行可执行文件 +CMD ["./app"] \ No newline at end of file From 50526835e815cb21eca61768fa063b8499d4d3dd Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 19:14:51 +0800 Subject: [PATCH 33/61] Invalid run/uses syntax for job:Build and test step:Checkout --- .gitea/workflows/go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 85173ab..3d230d3 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -10,7 +10,7 @@ jobs: steps: - name: Checkout - - uses: actions/checkout@v4 + uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v4 From 83211dc5d4bd53db38d1a16e96eec53bb9ae7028 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 19:25:39 +0800 Subject: [PATCH 34/61] direct docker --- .gitea/workflows/go.yaml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 3d230d3..a5aa726 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -4,25 +4,6 @@ on: branches: [ master ] jobs: - build: - name: Build and test - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: 1.21 - - - name: Build project - run: | - go build -v ./... - - name: Test with the Go CLI - run: go test - docker: needs: build runs-on: ubuntu-latest From fbb8f96b89b9881567b3d42d5c30d5693eeb967f Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 19:26:50 +0800 Subject: [PATCH 35/61] direct docker --- .gitea/workflows/go.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index a5aa726..28f7cb1 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -5,7 +5,6 @@ on: jobs: docker: - needs: build runs-on: ubuntu-latest steps: From 95a492bd109e522bbb4637a38c1c8795522bc9e5 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 19:37:28 +0800 Subject: [PATCH 36/61] update --- .gitea/workflows/go.yaml | 20 ++++++++++++++++++++ Dokerfile.yaml | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 28f7cb1..3d230d3 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -4,7 +4,27 @@ on: branches: [ master ] jobs: + build: + name: Build and test + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21 + + - name: Build project + run: | + go build -v ./... + - name: Test with the Go CLI + run: go test + docker: + needs: build runs-on: ubuntu-latest steps: diff --git a/Dokerfile.yaml b/Dokerfile.yaml index 255f378..8e6d25a 100644 --- a/Dokerfile.yaml +++ b/Dokerfile.yaml @@ -1,5 +1,5 @@ # 使用官方的 Go 运行时作为基础镜像 -FROM golang:1.18-alpine AS builder +FROM golang:latest AS builder # 设置工作目录 WORKDIR /app From fc24151cc7190da346620c207f1121204bbaa074 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 19:49:02 +0800 Subject: [PATCH 37/61] user gitea --- .gitea/workflows/go.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 3d230d3..61ced11 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -10,10 +10,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: https://gitea.com/actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: https://gitea.com/actions/setup-go@v4 with: go-version: 1.21 @@ -29,10 +29,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: https://gitea.com/actions/checkout@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: https://gitea.com/docker/setup-buildx-action@v3 - name: Build Docker image run: | From 5a65b3c961447f7f225a7fc155bf273dba1dc0b4 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 19:54:11 +0800 Subject: [PATCH 38/61] change version --- .gitea/workflows/go.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 61ced11..67f7fee 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -13,7 +13,7 @@ jobs: uses: https://gitea.com/actions/checkout@v4 - name: Set up Go - uses: https://gitea.com/actions/setup-go@v4 + uses: https://gitea.com/actions/setup-go@v3 with: go-version: 1.21 @@ -32,7 +32,7 @@ jobs: uses: https://gitea.com/actions/checkout@v4 - name: Set up Docker Buildx - uses: https://gitea.com/docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v3 - name: Build Docker image run: | From 332cc10751f07a6e52790d1cf905376294ec4ceb Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 19:57:26 +0800 Subject: [PATCH 39/61] gitea setup-buildx-action --- .gitea/workflows/go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 67f7fee..57094d0 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -32,7 +32,7 @@ jobs: uses: https://gitea.com/actions/checkout@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: https://gitea.com/docker/setup-buildx-action@v3 - name: Build Docker image run: | From b9a2821c88fa6cd2bc4910c08dae11b78e48f97c Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 20:15:28 +0800 Subject: [PATCH 40/61] jwt --- go.mod | 2 +- go.sum | 4 ++-- pkg/jwt/auth.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index fafac35..e1c59ef 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module go_blog go 1.20 require ( - github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/gin-gonic/gin v1.9.1 github.com/go-ini/ini v1.67.0 + github.com/golang-jwt/jwt v3.2.2+incompatible github.com/gorilla/websocket v1.5.1 golang.org/x/crypto v0.25.0 gorm.io/driver/mysql v1.5.6 diff --git a/go.sum b/go.sum index 6d3dfc4..2da2185 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,6 @@ github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583j github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= @@ -31,6 +29,8 @@ github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= diff --git a/pkg/jwt/auth.go b/pkg/jwt/auth.go index 77bf25e..1253913 100644 --- a/pkg/jwt/auth.go +++ b/pkg/jwt/auth.go @@ -11,8 +11,8 @@ import ( "go_blog/models" "time" - "github.com/dgrijalva/jwt-go" "github.com/gin-gonic/gin" + "github.com/golang-jwt/jwt" ) // 定义jwt载荷 From 1877c108f30f41ed63ca657e29de0db1ec877542 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 20:37:37 +0800 Subject: [PATCH 41/61] add go mod and proxy --- .gitea/workflows/go.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 57094d0..82bea4c 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -16,6 +16,8 @@ jobs: uses: https://gitea.com/actions/setup-go@v3 with: go-version: 1.21 + go111mode: on + goproxy: https://goproxy.cn,direct - name: Build project run: | From d39520aaed721286ae322d00dcb70b4defd9d5db Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 20:41:10 +0800 Subject: [PATCH 42/61] with go env --- .gitea/workflows/go.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 82bea4c..7ddbdb8 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -16,8 +16,9 @@ jobs: uses: https://gitea.com/actions/setup-go@v3 with: go-version: 1.21 - go111mode: on - goproxy: https://goproxy.cn,direct + go-env: + go111mode: on + goproxy: https://goproxy.cn,direct - name: Build project run: | From 3aa6e801a54c036b5a5a4ff83afb336c65864994 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 20:46:09 +0800 Subject: [PATCH 43/61] change env --- .gitea/workflows/go.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 7ddbdb8..ee58c9b 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -16,10 +16,10 @@ jobs: uses: https://gitea.com/actions/setup-go@v3 with: go-version: 1.21 - go-env: - go111mode: on - goproxy: https://goproxy.cn,direct - + env: + GOPROXY: https://goproxy.cn,direct + GO111mode: on + - name: Build project run: | go build -v ./... From 30d05257ba5cdae24c4a6b6852ff6436441f6e27 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 20:48:10 +0800 Subject: [PATCH 44/61] aa --- .gitea/workflows/go.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index ee58c9b..b01bb0a 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -1,7 +1,5 @@ name: Go build -on: - push: - branches: [ master ] +on: [push] jobs: build: @@ -19,7 +17,7 @@ jobs: env: GOPROXY: https://goproxy.cn,direct GO111mode: on - + - name: Build project run: | go build -v ./... From 1cc80f5f7b6449535b523b475baa13000b9cdd3d Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 22:25:13 +0800 Subject: [PATCH 45/61] new runner --- .gitea/workflows/go.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index b01bb0a..6ba4bfb 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -1,5 +1,8 @@ name: Go build -on: [push] +on: + push: + branches: + - master jobs: build: From 6b7a28ce6c98df336d27511ad0f1ead41daf7ee0 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 22:27:32 +0800 Subject: [PATCH 46/61] 1111 --- .gitea/workflows/go.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 6ba4bfb..c64e4b0 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -1,8 +1,8 @@ name: Go build on: - push: - branches: - - master + push: + branches: + - master jobs: build: From 28dae94ad8e4fcc5615b897b820ad37fcaf51c3e Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 22:32:41 +0800 Subject: [PATCH 47/61] test --- .gitea/workflows/demo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index b56c578..234989e 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -4,7 +4,7 @@ on: [push] jobs: container-job: - name: my first job + name: my first job test runs-on: ubuntu-latest container: image: golang:latest From 4ad4bc0f8ef9901defe439fd766e6b382de7387d Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 22:34:41 +0800 Subject: [PATCH 48/61] change go setup --- .gitea/workflows/go.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index c64e4b0..169714b 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -17,9 +17,8 @@ jobs: uses: https://gitea.com/actions/setup-go@v3 with: go-version: 1.21 - env: - GOPROXY: https://goproxy.cn,direct - GO111mode: on + go-proxy: https://goproxy.cn,direct + go-go111mode: on - name: Build project run: | From d3e52bb91c555eb72a1a2137a4f6d28c42e321e0 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 22:44:12 +0800 Subject: [PATCH 49/61] aa --- .gitea/workflows/go.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 169714b..da0459d 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -17,8 +17,8 @@ jobs: uses: https://gitea.com/actions/setup-go@v3 with: go-version: 1.21 + go-go111modules: on go-proxy: https://goproxy.cn,direct - go-go111mode: on - name: Build project run: | From 30f944ca354607709b82c8fdda23fc1cad0e0fa2 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 22:46:15 +0800 Subject: [PATCH 50/61] ttt --- .gitea/workflows/go.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index da0459d..05d5744 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -17,9 +17,10 @@ jobs: uses: https://gitea.com/actions/setup-go@v3 with: go-version: 1.21 - go-go111modules: on - go-proxy: https://goproxy.cn,direct - + env: + GOPROXY: https://goproxy.cn,direct + GO111MODULES: on + - name: Build project run: | go build -v ./... From 69958db82a489f362cff901f448a94c59176718b Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 22:46:50 +0800 Subject: [PATCH 51/61] aaf --- .gitea/workflows/go.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 05d5744..1ee88af 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -17,10 +17,10 @@ jobs: uses: https://gitea.com/actions/setup-go@v3 with: go-version: 1.21 - env: + go-env: | GOPROXY: https://goproxy.cn,direct GO111MODULES: on - + - name: Build project run: | go build -v ./... From 8c5cb21ec4d6ab918ea9573055181d5b77ae28aa Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 22:55:18 +0800 Subject: [PATCH 52/61] use echo --- .gitea/workflows/go.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 1ee88af..6c03eb6 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -17,9 +17,10 @@ jobs: uses: https://gitea.com/actions/setup-go@v3 with: go-version: 1.21 - go-env: | - GOPROXY: https://goproxy.cn,direct - GO111MODULES: on + - name: Set GOPROXY and GO111MODULES + run: | + echo "GOPROXY=https://goproxy.cn,direct" >> $GITHUB_ENV + echo "GO111MODULES: on" >> $GITHUB_ENV - name: Build project run: | From 41b21fac93c2a88efb291026286299c03ef37272 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 23:05:24 +0800 Subject: [PATCH 53/61] 111 --- .gitea/workflows/go.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 6c03eb6..9278c87 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -19,8 +19,8 @@ jobs: go-version: 1.21 - name: Set GOPROXY and GO111MODULES run: | - echo "GOPROXY=https://goproxy.cn,direct" >> $GITHUB_ENV - echo "GO111MODULES: on" >> $GITHUB_ENV + echo "GOPROXY=https://goproxy.cn,direct" >> $GITEA_ENV + echo "GO111MODULES: on" >> $GITEA_ENV - name: Build project run: | From 0aa07af0d41a8a28fd17cca4daf31dfeb469668b Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 23:12:25 +0800 Subject: [PATCH 54/61] without pre build --- .gitea/workflows/go.yaml | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/.gitea/workflows/go.yaml b/.gitea/workflows/go.yaml index 9278c87..1c79922 100644 --- a/.gitea/workflows/go.yaml +++ b/.gitea/workflows/go.yaml @@ -5,31 +5,8 @@ on: - master jobs: - build: - name: Build and test - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: https://gitea.com/actions/checkout@v4 - - - name: Set up Go - uses: https://gitea.com/actions/setup-go@v3 - with: - go-version: 1.21 - - name: Set GOPROXY and GO111MODULES - run: | - echo "GOPROXY=https://goproxy.cn,direct" >> $GITEA_ENV - echo "GO111MODULES: on" >> $GITEA_ENV - - - name: Build project - run: | - go build -v ./... - - name: Test with the Go CLI - run: go test - docker: - needs: build + name: build and run runs-on: ubuntu-latest steps: From ea8aea4ce28f5179b7569ee14a24e68b9556cdde Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 23:17:41 +0800 Subject: [PATCH 55/61] dockerfile add --- Dokerfile.yaml => Dockerfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Dokerfile.yaml => Dockerfile (100%) diff --git a/Dokerfile.yaml b/Dockerfile similarity index 100% rename from Dokerfile.yaml rename to Dockerfile From dcac6578dc74b476ab0420a62e483115aa019d30 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Thu, 31 Oct 2024 23:27:19 +0800 Subject: [PATCH 56/61] change go dockerfile --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8e6d25a..6dee961 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ # 使用官方的 Go 运行时作为基础镜像 FROM golang:latest AS builder - +ENV GO111MODULE=on \ + CGO_ENABLED=0 \ + GOOS=linux \ + GOARCH=amd64 \ + GOPROXY=https://goproxy.cn,direct # 设置工作目录 WORKDIR /app From 431ab136730a3270454810e4431d91d89a499cfb Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 1 Nov 2024 00:29:35 +0800 Subject: [PATCH 57/61] config file error --- Dockerfile | 10 +++++++--- conf/config.go | 1 + conf/config.yml | 2 +- main.go | 1 - 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6dee961..b6f9741 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,15 +14,19 @@ COPY . . # 构建可执行文件 RUN CGO_ENABLED=0 GOOS=linux go build -v -o app . + # 使用一个更小的基础镜像来减小最终镜像的大小 FROM alpine:latest - +# 时区设置成当前时区 +RUN apk add --no-cache tzdata +ENV TZ="Asia/Shanghai" # 设置工作目录 WORKDIR /root/ - # 从构建阶段复制可执行文件 COPY --from=builder /app/app . - +# 在容器目录 /root/ 创建一个目录 为config +RUN mkdir conf . +COPY --from=builder /app/conf/ ./conf/ # 暴露端口 EXPOSE 8080 diff --git a/conf/config.go b/conf/config.go index 4a26251..1b85507 100644 --- a/conf/config.go +++ b/conf/config.go @@ -85,6 +85,7 @@ func SetUp1() { mysqlHost := viper.GetString("mysql.Host") jwtSecretKey := viper.GetString("jwt.SecretKey") serverPort := viper.GetInt("server.Port") + DataBase = viper.Get("database") templateGlob := viper.GetString("project.TemplateGlob") // 打印获取到的配置值 diff --git a/conf/config.yml b/conf/config.yml index e4a4acc..d4fcf41 100644 --- a/conf/config.yml +++ b/conf/config.yml @@ -1,4 +1,4 @@ -mysql: +database: Type: mysql Host: 127.0.0.1 Port: 3306 diff --git a/main.go b/main.go index f33ce57..b0cad68 100644 --- a/main.go +++ b/main.go @@ -36,7 +36,6 @@ func init() { flag.Parse() conf.SetUp() - conf.SetUp1() models.SetUp(isOrmDebug) } From 07c685c9707af36f9312a2ce71b669b1582da4d5 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 1 Nov 2024 00:33:17 +0800 Subject: [PATCH 58/61] aafff --- conf/config.go | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/config.go b/conf/config.go index 1b85507..4a26251 100644 --- a/conf/config.go +++ b/conf/config.go @@ -85,7 +85,6 @@ func SetUp1() { mysqlHost := viper.GetString("mysql.Host") jwtSecretKey := viper.GetString("jwt.SecretKey") serverPort := viper.GetInt("server.Port") - DataBase = viper.Get("database") templateGlob := viper.GetString("project.TemplateGlob") // 打印获取到的配置值 From 9f1f7ea937d2b37d46508b7e09736112496b9733 Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 1 Nov 2024 01:14:18 +0800 Subject: [PATCH 59/61] mysql change --- conf/conf.ini | 6 +++--- conf/config.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conf/conf.ini b/conf/conf.ini index c9d2e5e..4639c0c 100644 --- a/conf/conf.ini +++ b/conf/conf.ini @@ -1,9 +1,9 @@ [mysql] Type = mysql -Host = 127.0.0.1 +Host = 47.93.160.42 Port = 3306 -User = root -Password = root +User = blog +Password = qI7=bL4@iJ DBName = blog Charset = utf8mb4 Prefix = gin_ diff --git a/conf/config.yml b/conf/config.yml index d4fcf41..56a66b7 100644 --- a/conf/config.yml +++ b/conf/config.yml @@ -2,8 +2,8 @@ database: Type: mysql Host: 127.0.0.1 Port: 3306 - User: root - Password: root + User: blog + Password: qI7=bL4@iJ DBName: blog Charset: utf8mb4 Prefix: gin_ From a4d668d1f37975524df380984900a70f7d78e76e Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 1 Nov 2024 01:19:55 +0800 Subject: [PATCH 60/61] templage --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index b6f9741..99bd3db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,8 @@ COPY --from=builder /app/app . # 在容器目录 /root/ 创建一个目录 为config RUN mkdir conf . COPY --from=builder /app/conf/ ./conf/ +COPY --from=builder /app/templates/ ./conf/ + # 暴露端口 EXPOSE 8080 From c628419559368f0270c2573d91a06a1a9531d53a Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 1 Nov 2024 01:24:57 +0800 Subject: [PATCH 61/61] templates --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 99bd3db..7a39d1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ COPY --from=builder /app/app . # 在容器目录 /root/ 创建一个目录 为config RUN mkdir conf . COPY --from=builder /app/conf/ ./conf/ -COPY --from=builder /app/templates/ ./conf/ +COPY --from=builder /app/templates/ ./templates/ # 暴露端口 EXPOSE 8080