Skip to content

Commit

Permalink
Optimize Github CI
Browse files Browse the repository at this point in the history
  • Loading branch information
SleepyHeeead committed Jan 29, 2024
1 parent 68360e2 commit cec9a5d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 46 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 20 additions & 20 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
50 changes: 27 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -15,19 +12,11 @@
- [添加域名](#添加域名)
- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [日志清理](#日志清理)
- [Maintainers](#maintainers)
- [Contributing](#contributing)
- [License](#license)

# Update

- 20200330
集成前端至根路径,如: <http://127.0.0.1:8002/>

> 注:如需使用集成的前端,项目部署请 clone 仓库后自行编译,并在代码根目录启动服务。或者可 nginx 单独配置 root 至 public 目录的 index.html。

# Dependencies

本服务依赖于 Redis 提供长短链接映射关系存储,你需要本地安装 Redis 服务来保证短链接服务的正常运行。
Expand Down Expand Up @@ -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
Expand All @@ -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 <<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

Expand All @@ -134,4 +138,4 @@ Small note: If editing the README, please conform to the [standard-readme](https

## License

MIT © 2020 CareyWang
MIT © 2024 CareyWang

0 comments on commit cec9a5d

Please sign in to comment.