From cec9a5de4659a5b7229713dd05958d7fa836b98b Mon Sep 17 00:00:00 2001 From: CareyWong Date: Mon, 29 Jan 2024 15:09:35 +0800 Subject: [PATCH] Optimize Github CI --- .github/workflows/docker_build_push.yml | 6 +-- .github/workflows/go.yml | 40 ++++++++++---------- README.md | 50 +++++++++++++------------ 3 files changed, 50 insertions(+), 46 deletions(-) diff --git a/.github/workflows/docker_build_push.yml b/.github/workflows/docker_build_push.yml index 9fbddab..9ad8e42 100644 --- a/.github/workflows/docker_build_push.yml +++ b/.github/workflows/docker_build_push.yml @@ -14,16 +14,16 @@ jobs: uses: actions/checkout@master - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Log in to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push Docker image - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: . platforms: linux/386,linux/amd64,linux/arm64,linux/ppc64le,linux/arm/v7 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 930603b..b7154e8 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -9,19 +9,19 @@ jobs: name: Linux amd64 build runs-on: ubuntu-latest steps: - - name: Set up Go 1.20 - uses: actions/setup-go@v3 + - name: Set up Go 1.21 + uses: actions/setup-go@v4 with: - go-version: '^1.20.4' + go-version: '^1.21.6' id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@master - name: Install dependencies run: sudo apt install gcc-aarch64-linux-gnu - name: Build run: /bin/sh -c "chmod +x scripts/build_linux_amd64.sh && bash scripts/build_linux_amd64.sh" - name: Upload - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: myurls-linux-amd64 path: build/myurls-linux-amd64.tar.gz @@ -31,19 +31,19 @@ jobs: runs-on: ubuntu-latest # runs-on: self-hosted steps: - - name: Set up Go 1.20 - uses: actions/setup-go@v3 + - name: Set up Go 1.21 + uses: actions/setup-go@v4 with: - go-version: '^1.20.4' + go-version: '^1.21.6' id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@master - name: Install dependencies run: sudo apt install gcc-aarch64-linux-gnu - name: Build run: /bin/sh -c "chmod +x scripts/build_linux_arm64.sh && bash scripts/build_linux_arm64.sh" - name: Upload - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: myurls-linux-arm64 path: build/myurls-linux-arm64.tar.gz @@ -52,19 +52,19 @@ jobs: # name: Darwin amd64 build # runs-on: ubuntu-latest # steps: - # - name: Set up Go 1.20 - # uses: actions/setup-go@v3 + # - name: Set up Go 1.21 + # uses: actions/setup-go@v4 # with: - # go-version: '^1.20.4' + # go-version: '^1.21.6' # id: go # - name: Check out code into the Go module directory - # uses: actions/checkout@v3 + # uses: actions/checkout@master # - name: Install dependencies # run: sudo apt install gcc-aarch64-linux-gnu # - name: Build # run: /bin/sh -c "chmod +x scripts/build_darwin_amd64.sh && bash scripts/build_darwin_amd64.sh" # - name: Upload - # uses: actions/upload-artifact@v3 + # uses: actions/upload-artifact@v4 # with: # name: myurls-darwin-amd64.tar.gz # path: build/myurls-darwin-amd64.tar.gz @@ -73,19 +73,19 @@ jobs: name: Windows x64 build runs-on: ubuntu-latest steps: - - name: Set up Go 1.20 - uses: actions/setup-go@v3 + - name: Set up Go 1.21 + uses: actions/setup-go@v4 with: - go-version: '^1.20.4' + go-version: '^1.21.6' id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@master - name: Install dependencies run: sudo apt install gcc-aarch64-linux-gnu - name: Build run: /bin/sh -c "chmod +x scripts/build_windows_x64.sh && bash scripts/build_windows_x64.sh" - name: Upload - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: myurls-windows-x64.tar.gz path: build/myurls-windows-x64.tar.gz diff --git a/README.md b/README.md index 69667f5..e0af06f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,9 @@ # MyUrls -基于 Go 1.21 与 Redis 实现的本地短链接服务,用于缩短请求链接与短链接还原。 +基于 Go 1.21 与 Redis 实现的本地短链接服务,用于缩短 URL 与短链接还原。 ## Table of Contents -- [MyUrls](#myurls) - - [Table of Contents](#table-of-contents) -- [Update](#update) - [Dependencies](#dependencies) - [Docker](#docker) - [Deploy Online](#deploy-online) @@ -15,19 +12,11 @@ - [添加域名](#添加域名) - [Install](#install) - [Usage](#usage) - - [API](#api) + - [日志清理](#日志清理) - [Maintainers](#maintainers) - [Contributing](#contributing) - [License](#license) -# Update - -- 20200330 - 集成前端至根路径,如: 。 - - > 注:如需使用集成的前端,项目部署请 clone 仓库后自行编译,并在代码根目录启动服务。或者可 nginx 单独配置 root 至 public 目录的 index.html。 - - # Dependencies 本服务依赖于 Redis 提供长短链接映射关系存储,你需要本地安装 Redis 服务来保证短链接服务的正常运行。 @@ -93,12 +82,10 @@ bash release.sh ## Usage -前往 [Release](https://github.com/CareyWang/MyUrls/releases) 下载对应平台可执行文件。 +前往 [Actions](https://github.com/CareyWang/MyUrls/actions/workflows/go.yml) 下载对应平台可执行文件。 ```shell script -./build/linux-amd64-myurls -h - -Usage of ./build/linux-amd64-myurls: +Usage: -conn string Redis连接,格式: host:port (default "127.0.0.1:6379") -domain string @@ -114,13 +101,30 @@ Usage of ./build/linux-amd64-myurls: 建议配合 [pm2](https://pm2.keymetrics.io/) 开启守护进程。 ```shell script -pm2 start myurls --watch --name myurls -- -domain example.com +pm2 start myurls --name myurls -- -domain example.com ``` -## API - -[参考文档](https://myurls.mydoc.li) - +### 日志清理 + +假定工作目录为 `/app`,可基于 logrotate 配置应用日志的自动轮转与清理。可参考示例配置,每天轮转一次日志文件,保留最近7天 + +```shell +tee > /etc/logrotate.d/myurls <