Optimize Github CI
This commit is contained in:
parent
68360e2508
commit
cec9a5de46
6
.github/workflows/docker_build_push.yml
vendored
6
.github/workflows/docker_build_push.yml
vendored
@ -14,16 +14,16 @@ jobs:
|
|||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/386,linux/amd64,linux/arm64,linux/ppc64le,linux/arm/v7
|
platforms: linux/386,linux/amd64,linux/arm64,linux/ppc64le,linux/arm/v7
|
||||||
|
|||||||
40
.github/workflows/go.yml
vendored
40
.github/workflows/go.yml
vendored
@ -9,19 +9,19 @@ jobs:
|
|||||||
name: Linux amd64 build
|
name: Linux amd64 build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go 1.20
|
- name: Set up Go 1.21
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '^1.20.4'
|
go-version: '^1.21.6'
|
||||||
id: go
|
id: go
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@master
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt install gcc-aarch64-linux-gnu
|
run: sudo apt install gcc-aarch64-linux-gnu
|
||||||
- name: Build
|
- name: Build
|
||||||
run: /bin/sh -c "chmod +x scripts/build_linux_amd64.sh && bash scripts/build_linux_amd64.sh"
|
run: /bin/sh -c "chmod +x scripts/build_linux_amd64.sh && bash scripts/build_linux_amd64.sh"
|
||||||
- name: Upload
|
- name: Upload
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: myurls-linux-amd64
|
name: myurls-linux-amd64
|
||||||
path: build/myurls-linux-amd64.tar.gz
|
path: build/myurls-linux-amd64.tar.gz
|
||||||
@ -31,19 +31,19 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# runs-on: self-hosted
|
# runs-on: self-hosted
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go 1.20
|
- name: Set up Go 1.21
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '^1.20.4'
|
go-version: '^1.21.6'
|
||||||
id: go
|
id: go
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@master
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt install gcc-aarch64-linux-gnu
|
run: sudo apt install gcc-aarch64-linux-gnu
|
||||||
- name: Build
|
- name: Build
|
||||||
run: /bin/sh -c "chmod +x scripts/build_linux_arm64.sh && bash scripts/build_linux_arm64.sh"
|
run: /bin/sh -c "chmod +x scripts/build_linux_arm64.sh && bash scripts/build_linux_arm64.sh"
|
||||||
- name: Upload
|
- name: Upload
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: myurls-linux-arm64
|
name: myurls-linux-arm64
|
||||||
path: build/myurls-linux-arm64.tar.gz
|
path: build/myurls-linux-arm64.tar.gz
|
||||||
@ -52,19 +52,19 @@ jobs:
|
|||||||
# name: Darwin amd64 build
|
# name: Darwin amd64 build
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
# steps:
|
# steps:
|
||||||
# - name: Set up Go 1.20
|
# - name: Set up Go 1.21
|
||||||
# uses: actions/setup-go@v3
|
# uses: actions/setup-go@v4
|
||||||
# with:
|
# with:
|
||||||
# go-version: '^1.20.4'
|
# go-version: '^1.21.6'
|
||||||
# id: go
|
# id: go
|
||||||
# - name: Check out code into the Go module directory
|
# - name: Check out code into the Go module directory
|
||||||
# uses: actions/checkout@v3
|
# uses: actions/checkout@master
|
||||||
# - name: Install dependencies
|
# - name: Install dependencies
|
||||||
# run: sudo apt install gcc-aarch64-linux-gnu
|
# run: sudo apt install gcc-aarch64-linux-gnu
|
||||||
# - name: Build
|
# - name: Build
|
||||||
# run: /bin/sh -c "chmod +x scripts/build_darwin_amd64.sh && bash scripts/build_darwin_amd64.sh"
|
# run: /bin/sh -c "chmod +x scripts/build_darwin_amd64.sh && bash scripts/build_darwin_amd64.sh"
|
||||||
# - name: Upload
|
# - name: Upload
|
||||||
# uses: actions/upload-artifact@v3
|
# uses: actions/upload-artifact@v4
|
||||||
# with:
|
# with:
|
||||||
# name: myurls-darwin-amd64.tar.gz
|
# name: myurls-darwin-amd64.tar.gz
|
||||||
# path: build/myurls-darwin-amd64.tar.gz
|
# path: build/myurls-darwin-amd64.tar.gz
|
||||||
@ -73,19 +73,19 @@ jobs:
|
|||||||
name: Windows x64 build
|
name: Windows x64 build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go 1.20
|
- name: Set up Go 1.21
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '^1.20.4'
|
go-version: '^1.21.6'
|
||||||
id: go
|
id: go
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@master
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt install gcc-aarch64-linux-gnu
|
run: sudo apt install gcc-aarch64-linux-gnu
|
||||||
- name: Build
|
- name: Build
|
||||||
run: /bin/sh -c "chmod +x scripts/build_windows_x64.sh && bash scripts/build_windows_x64.sh"
|
run: /bin/sh -c "chmod +x scripts/build_windows_x64.sh && bash scripts/build_windows_x64.sh"
|
||||||
- name: Upload
|
- name: Upload
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: myurls-windows-x64.tar.gz
|
name: myurls-windows-x64.tar.gz
|
||||||
path: build/myurls-windows-x64.tar.gz
|
path: build/myurls-windows-x64.tar.gz
|
||||||
|
|||||||
46
README.md
46
README.md
@ -1,12 +1,9 @@
|
|||||||
# MyUrls
|
# MyUrls
|
||||||
|
|
||||||
基于 Go 1.21 与 Redis 实现的本地短链接服务,用于缩短请求链接与短链接还原。
|
基于 Go 1.21 与 Redis 实现的本地短链接服务,用于缩短 URL 与短链接还原。
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
- [MyUrls](#myurls)
|
|
||||||
- [Table of Contents](#table-of-contents)
|
|
||||||
- [Update](#update)
|
|
||||||
- [Dependencies](#dependencies)
|
- [Dependencies](#dependencies)
|
||||||
- [Docker](#docker)
|
- [Docker](#docker)
|
||||||
- [Deploy Online](#deploy-online)
|
- [Deploy Online](#deploy-online)
|
||||||
@ -15,19 +12,11 @@
|
|||||||
- [添加域名](#添加域名)
|
- [添加域名](#添加域名)
|
||||||
- [Install](#install)
|
- [Install](#install)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [API](#api)
|
- [日志清理](#日志清理)
|
||||||
- [Maintainers](#maintainers)
|
- [Maintainers](#maintainers)
|
||||||
- [Contributing](#contributing)
|
- [Contributing](#contributing)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
|
|
||||||
# Update
|
|
||||||
|
|
||||||
- 20200330
|
|
||||||
集成前端至根路径,如: <http://127.0.0.1:8002/>。
|
|
||||||
|
|
||||||
> 注:如需使用集成的前端,项目部署请 clone 仓库后自行编译,并在代码根目录启动服务。或者可 nginx 单独配置 root 至 public 目录的 index.html。
|
|
||||||
|
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
本服务依赖于 Redis 提供长短链接映射关系存储,你需要本地安装 Redis 服务来保证短链接服务的正常运行。
|
本服务依赖于 Redis 提供长短链接映射关系存储,你需要本地安装 Redis 服务来保证短链接服务的正常运行。
|
||||||
@ -93,12 +82,10 @@ bash release.sh
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
前往 [Release](https://github.com/CareyWang/MyUrls/releases) 下载对应平台可执行文件。
|
前往 [Actions](https://github.com/CareyWang/MyUrls/actions/workflows/go.yml) 下载对应平台可执行文件。
|
||||||
|
|
||||||
```shell script
|
```shell script
|
||||||
./build/linux-amd64-myurls -h
|
Usage:
|
||||||
|
|
||||||
Usage of ./build/linux-amd64-myurls:
|
|
||||||
-conn string
|
-conn string
|
||||||
Redis连接,格式: host:port (default "127.0.0.1:6379")
|
Redis连接,格式: host:port (default "127.0.0.1:6379")
|
||||||
-domain string
|
-domain string
|
||||||
@ -114,13 +101,30 @@ Usage of ./build/linux-amd64-myurls:
|
|||||||
建议配合 [pm2](https://pm2.keymetrics.io/) 开启守护进程。
|
建议配合 [pm2](https://pm2.keymetrics.io/) 开启守护进程。
|
||||||
|
|
||||||
```shell script
|
```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 <<EOF
|
||||||
|
/app/logs/access.log {
|
||||||
|
daily
|
||||||
|
rotate 7
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
copytruncate
|
||||||
|
create 640 root adm
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# 测试是否正常工作,不会实际执行切割
|
||||||
|
logrotate -d /etc/logrotate.d/myurls
|
||||||
|
```
|
||||||
|
|
||||||
## Maintainers
|
## Maintainers
|
||||||
|
|
||||||
@ -134,4 +138,4 @@ Small note: If editing the README, please conform to the [standard-readme](https
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT © 2020 CareyWang
|
MIT © 2024 CareyWang
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user