Skip to content

Commit ff50cac

Browse files
committed
ci: build and push images
1 parent 8b3b126 commit ff50cac

File tree

4 files changed

+215
-9
lines changed

4 files changed

+215
-9
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build and Push Docker Images
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
env:
8+
DOCKERHUB_USERNAME: aflybird0
9+
GHCR_USERNAME: aflybird0
10+
IMAGE_NAME: cubox-archiver
11+
TAG: ${{ github.ref_name }}
12+
13+
jobs:
14+
build-and-push:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v2
22+
- name: Set up Docker Buildx
23+
id: buildx
24+
uses: docker/setup-buildx-action@v2
25+
- name: Available platforms
26+
run: echo ${{ steps.buildx.outputs.platforms }}
27+
28+
- name: Login to DockerHub
29+
uses: docker/login-action@v1
30+
with:
31+
username: ${{ env.DOCKERHUB_USERNAME }}
32+
password: ${{ secrets.DOCKERHUB_TOKEN }}
33+
34+
- name: Login to GitHub Container Registry
35+
uses: docker/login-action@v1
36+
with:
37+
registry: ghcr.io
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Build and Push Docker Images
42+
uses: docker/build-push-action@v4
43+
with:
44+
push: true
45+
platforms: linux/amd64,linux/arm64
46+
tags: |
47+
docker.io/${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
48+
docker.io/${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
49+
ghcr.io/${{ env.GHCR_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
50+
ghcr.io/${{ env.GHCR_USERNAME }}/${{ env.IMAGE_NAME }}:latest
51+
context: .

.github/workflows/release.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ on:
55
# run only against tags
66
tags:
77
- '*'
8+
env:
9+
DOCKERHUB_USERNAME: aflybird0
10+
GHCR_USERNAME: aflybird0
11+
USERNAME: aflybird0
12+
IMAGE_NAME: cubox-archiver
13+
TAG: ${{ github.ref_name }}
814

915
permissions:
1016
contents: write
11-
# packages: write
17+
packages: write
1218
# issues: write
1319

1420
jobs:
@@ -23,6 +29,18 @@ jobs:
2329
with:
2430
go-version: '>=1.20'
2531
cache: true
32+
# - name: Login to DockerHub
33+
# uses: docker/login-action@v1
34+
# with:
35+
# username: ${{ env.DOCKERHUB_USERNAME }}
36+
# password: ${{ secrets.DOCKERHUB_TOKEN }}
37+
#
38+
# - name: Login to GitHub Container Registry
39+
# uses: docker/login-action@v1
40+
# with:
41+
# registry: ghcr.io
42+
# username: ${{ github.actor }}
43+
# password: ${{ secrets.GITHUB_TOKEN }}
2644
# More assembly might be required: Docker logins, GPG, etc. It all depends
2745
# on your needs.
2846
- uses: goreleaser/goreleaser-action@v4
@@ -33,6 +51,8 @@ jobs:
3351
args: release --clean
3452
env:
3553
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
USERNAME: ${{ env.USERNAME }}
3655
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro'
3756
# distribution:
3857
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
58+
TAG: ${{ env.TAG }}

.goreleaser.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,108 @@ builds:
1616
- linux
1717
- windows
1818
- darwin
19+
#dockers:
20+
# - use: buildx
21+
# ids:
22+
# - cubox-archiver
23+
# goos: linux
24+
# goarch: amd64
25+
# image_templates:
26+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-amd64
27+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:latest-amd64
28+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-amd64
29+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:latest-amd64
30+
# dockerfile: Dockerfile
31+
# build_flag_templates:
32+
# - --pull
33+
# - --platform=linux/amd64
34+
# - --label=cn.aflybird.image.created={{.Date}}
35+
# - --label=cn.aflybird.image.title=cubox-archiver
36+
# - --label=cn.aflybird.image.revision={{.ShortCommit}}
37+
# - --label=cn.aflybird.image.version={{.Tag }}
38+
# - --label=cn.aflybird.image.auth={{ .Env.USERNAME }}
39+
# - use: buildx
40+
# ids:
41+
# - cubox-archiver
42+
# goos: linux
43+
# goarch: arm64
44+
# image_templates:
45+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-arm64
46+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:latest-arm64
47+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-arm64
48+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:latest-arm64
49+
# dockerfile: Dockerfile
50+
# build_flag_templates:
51+
# - --pull
52+
# - --platform=linux/arm64
53+
# - --label=cn.aflybird.image.created={{.Date}}
54+
# - --label=cn.aflybird.image.title=cubox-archiver
55+
# - --label=cn.aflybird.image.revision={{.ShortCommit}}
56+
# - --label=cn.aflybird.image.version={{.Tag }}
57+
# - --label=cn.aflybird.image.auth={{ .Env.USERNAME }}
58+
# - use: buildx
59+
# ids:
60+
# - cubox-archiver
61+
# goos: darwin
62+
# goarch: arm64
63+
# image_templates:
64+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-darwin-arm64
65+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:latest-darwin-arm64
66+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-darwin-arm64
67+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:latest-darwin-arm64
68+
# dockerfile: Dockerfile
69+
# build_flag_templates:
70+
# - --pull
71+
# - --platform=darwin/arm64
72+
# - --label=cn.aflybird.image.created={{.Date}}
73+
# - --label=cn.aflybird.image.title=cubox-archiver
74+
# - --label=cn.aflybird.image.revision={{.ShortCommit}}
75+
# - --label=cn.aflybird.image.version={{.Tag }}
76+
# - --label=cn.aflybird.image.auth={{ .Env.USERNAME }}
77+
# - use: buildx
78+
# ids:
79+
# - cubox-archiver
80+
# goos: darwin
81+
# goarch: amd64
82+
# image_templates:
83+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-darwin-amd64
84+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:latest-darwin-amd64
85+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-darwin-amd64
86+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:latest-darwin-amd64
87+
# dockerfile: Dockerfile
88+
# build_flag_templates:
89+
# - --pull
90+
# - --platform=darwin/amd64
91+
# - --label=cn.aflybird.image.created={{.Date}}
92+
# - --label=cn.aflybird.image.title=cubox-archiver
93+
# - --label=cn.aflybird.image.revision={{.ShortCommit}}
94+
# - --label=cn.aflybird.image.version={{.Tag }}
95+
# - --label=cn.aflybird.image.auth={{ .Env.USERNAME }}
96+
#docker_manifests:
97+
# - name_template: ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}
98+
# image_templates:
99+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-amd64
100+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-arm64
101+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-darwin-arm64
102+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-darwin-amd64
103+
# - name_template: ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:latest
104+
# image_templates:
105+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:latest-amd64
106+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:latest-arm64
107+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:latest-darwin-arm64
108+
# - ghcr.io/{{ .Env.USERNAME }}/cubox-archiver:latest-darwin-amd64
109+
# - name_template: docker.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}
110+
# image_templates:
111+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-amd64
112+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-arm64
113+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-darwin-arm64
114+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:{{ .Tag }}-darwin-amd64
115+
# - name_template: docker.io/{{ .Env.USERNAME }}/cubox-archiver:latest
116+
# image_templates:
117+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:latest-amd64
118+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:latest-arm64
119+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:latest-darwin-arm64
120+
# - docker.io/{{ .Env.USERNAME }}/cubox-archiver:latest-darwin-amd64
19121
archives:
20122
- replacements:
21123
darwin: Darwin

README.md

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,65 @@
3030

3131
![Notion归档效果-画廊](images/notion-gallery.png)
3232

33-
## 使用
33+
## 基本使用
3434

35-
先去 [Release 页](https://github.com/aFlyBird0/cubox-archiver/releases)下载二进制文件,Linux 和 macOS 用 `chmod +x` 给可执行权限。
35+
术语介绍:
36+
37+
1. 程序形态:本质上是个命令行工具。可以下载二进制文件;也提供了 Docker 镜像,可以用 Docker、Kubernetes CronJob 等方式运行;也可以用定时的 GitHub Action 运行。
38+
2. 数据源:Cubox 的稍后读列表。(目前只支持归档后的数据)
39+
3. 归档器:把数据源的数据同步到其他地方的工具。一个数据源可以同时归档到多个归档器。
40+
4. 配置:可以通过配置文件传入配置,也可以通过命令行参数传入配置。
41+
42+
## 支持的归档器
3643

37-
如果使用 Notion 作为归档器(虽然现在只支持Notion),请先创建一个 Notion 机器人,然后选定一个页面把机器人 Connection 进来。
44+
### Notion
45+
46+
请先创建一个 Notion 机器人,然后选定一个页面把机器人 Connection 进来。
3847

3948
1. 运行一次程序,传入 page id,这时候会提示你已经自动创建了一个新数据库
4049
2. 把新数据库的 database id 写到配置文件里,再运行,就真正启动了
4150

42-
配置相关往下看:
51+
### CSV 文件
52+
53+
开发中,建议仅用于测试。
4354

44-
### 用文件传入配置
55+
## 运行
56+
57+
### 使用二进制文件
58+
59+
先去 [Release 页](https://github.com/aFlyBird0/cubox-archiver/releases)下载二进制文件,Linux 和 macOS 用 `chmod +x` 给可执行权限。
60+
61+
1. 用文件传入配置
4562

4663
```bash
4764
./cubox-archiver from-file -f config.yaml
4865
```
4966

50-
具体配置看 `config.example.yaml`
67+
参数的详细解释,看 `config.example.yaml`
5168

52-
### 用命令行参数一个个传入配置
69+
2. 用命令行参数一个个传入配置
5370

5471
```bash
5572
./cubox-archiver from-flag --help
5673
```
5774

58-
然后根据提示自己拼参数。对于参数的详细解释,可以看 `config.example.yaml`
75+
然后根据提示自己拼参数。
76+
77+
### 使用 Docker(目前只支持linux)
78+
79+
1. 用文件传入配置
80+
81+
```bash
82+
docker run -v <主机的配置文件绝对路径/config.yaml>:/config.yaml aflybird0/cubox-archiver:latest from-file -f config.yaml
83+
```
84+
85+
2. 用命令行参数一个个传入配置
86+
87+
```bash
88+
docker run aflybird0/cubox-archiver:latest from-flag --help
89+
```
90+
91+
然后根据提示自己拼参数。
5992

6093
## 文档没写的
6194

0 commit comments

Comments
 (0)