Skip to content

Commit

Permalink
feat: 首次提交
Browse files Browse the repository at this point in the history
  • Loading branch information
eryajf committed Jul 2, 2023
0 parents commit b5bef18
Show file tree
Hide file tree
Showing 49 changed files with 3,928 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: 🙋 问题交流
about: 有任何问题,都可以在这里交流。
title: "🙋 简明扼要起个标题"
labels: ["question"]
---

## 问题反馈

- 搜索打开和关闭的 [GitHub 问题](https://github.com/eryajf/chatgpt-wecom/issues),请勿重复提交issue。

**重要:提交问题时,请务必带上输出日志,以及个人排查的成果。**
7 changes: 7 additions & 0 deletions .github/pull-request-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

**在提出此拉取请求时,我确认了以下几点(请复选框):**

- [ ] 我已阅读并理解[贡献者指南](https://github.com/eryajf/chatgpt-wecom/blob/main/CONTRIBUTING.md)
- [ ] 我已检查没有与此请求重复的拉取请求。
- [ ] 我已经考虑过,并确认这份呈件对其他人很有价值。
- [ ] 我接受此提交可能不会被使用,并根据维护人员的意愿关闭拉取请求。
42 changes: 42 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
name-template: 'v$NEXT_PATCH_VERSION 🌈'
tag-template: 'v$NEXT_PATCH_VERSION'
version-template: $MAJOR.$MINOR.$PATCH
# Emoji reference: https://gitmoji.carloscuesta.me/
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- 'kind/feature'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- 'regression'
- 'kind/bug'
- title: 📝 Documentation updates
labels:
- 'doc'
- 'documentation'
- 'kind/doc'
- title: 👻 Maintenance
labels:
- chore
- dependencies
- 'kind/chore'
- 'kind/dep'
- title: 🚦 Tests
labels:
- test
- tests
exclude-labels:
- reverted
- no-changelog
- skip-changelog
- invalid
change-template: '* $TITLE (#$NUMBER) @$AUTHOR'
template: |
## What’s Changed
$CHANGES
80 changes: 80 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# This is a basic workflow to help you get started with Actions

name: build docker image

# Controls when the action will run.
on:
push:
branches:
- main
release:
types: [created,published] # 表示在创建新的 Release 时触发

# Allows you to run this workflow manually from the Actions tab
# 可以手动触发
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
tags:
description: 'Test scenario tags'

jobs:
buildx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push to DockerHub
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
# 所需要的体系结构,可以在 Available platforms 步骤中获取所有的可用架构
platforms: linux/amd64,linux/arm64/v8
# 镜像推送时间
push: ${{ github.event_name != 'pull_request' }}
# 给清单打上多个标签
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/chatgpt-wecom:${{ env.GITHUB_REF_NAME }}
${{ secrets.DOCKERHUB_USERNAME }}/chatgpt-wecom:latest
# 镜像推送到 阿里云仓库
- name: Login to the Ali Registry
uses: docker/login-action@v2
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALIHUB_USERNAME }}
password: ${{ secrets.ALIHUB_TOKEN }}

- name: Build and push to Ali
uses: docker/build-push-action@v3
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALIHUB_USERNAME }}/chatgpt-wecom:${{ env.GITHUB_REF_NAME }}
registry.cn-hangzhou.aliyuncs.com/${{ secrets.ALIHUB_USERNAME }}/chatgpt-wecom:latest
26 changes: 26 additions & 0 deletions .github/workflows/go-binary-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build

on:
release:
types: [created,published] # 表示在创建新的 Release 时触发

jobs:
build-go-binary:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin] # 需要打包的系统
goarch: [amd64, arm64] # 需要打包的架构
exclude: # 排除某些平台和架构
- goarch: arm64
goos: windows
steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }} # 一个默认的变量,用来实现往 Release 中添加文件
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: 1.18 # 可以指定编译使用的 Golang 版本
binary_name: "chatgpt-wecom" # 可以指定二进制文件的名称
extra_files: LICENSE config.example.yml prompt.yml README.md # 需要包含的额外文件
20 changes: 20 additions & 0 deletions .github/workflows/reademe-contributors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Generate a list of contributors

on:
push:
branches:
- main

jobs:
contrib-readme-en-job:
runs-on: ubuntu-latest
name: A job to automate contrib in readme
steps:
- name: Contribute List
uses: akhilmhdh/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
image_size: 75
columns_per_row: 8
commit_message: '🫶 更新贡献者列表'
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
# pull_request_target event is required for autolabeler to support PRs from forks
# pull_request_target:
# types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 11 additions & 0 deletions .github/workflows/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
on: push
name: Automatic Generation TOC
jobs:
generateTOC:
name: TOC Generator
runs-on: ubuntu-latest
steps:
- uses: technote-space/toc-generator@v4
with:
TOC_TITLE: "**目录**"
MAX_HEADER_LEVEL: 4
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
.idea/
.vscode/

chatgpt-wecom

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
config.yml
wecom.sqlite
tmp
test/
images/
data/
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 贡献者指南

欢迎反馈、bug报告和拉取请求,可点击[issue](https://github.com/eryajf/chatgpt-wecom/issues) 提交.

如果你是第一次进行GitHub的协作,可参阅: [协同开发流程](https://eryajf.github.io/HowToStartOpenSource/views/01-basic-content/03-collaborative-development-process.html)

## 注意事项

- 如果你的变更中新增或者减少了配置,那么需要注意有这么几个地方需要同步调整:

- [config.go](https://github.com/eryajf/chatgpt-wecom/blob/main/config/config.go)
- [config.example.yml](https://github.com/eryajf/chatgpt-wecom/blob/main/config.example.yml)
- [docker-compose.yml](https://github.com/eryajf/chatgpt-wecom/blob/main/docker-compose.yml)
- [README.md](https://github.com/eryajf/chatgpt-wecom/blob/main/README.md)
- docker [启动命令](https://github.com/eryajf/chatgpt-wecom/blob/main/README.md#docker%E9%83%A8%E7%BD%B2)中要添加。
- [配置文件说明](https://github.com/eryajf/chatgpt-wecom/blob/main/README.md#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E)要添加。

一定要检查这几个地方,而且注意务必加好注释,否则将会影响用户升级体验新功能。

- 关于配置管理还有一个很重要的点在于,`config.example.yml`中的配置务必配置为最大权限,以免出现用户首次部署就无法走到正常逻辑的情况。

- 请务必检查你的提交,是否包含secret,api_key之类的信息,如果要贴示例,注意数据脱敏。

- 如果新增了功能性的模板,则务必在[使用指南](./docs/userGuide.md)中添加对应说明文档。
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM golang:1.18.10-alpine3.16 AS builder

# ENV GOPROXY https://goproxy.io

RUN mkdir /app
ADD . /app/
WORKDIR /app
RUN go build -o chatgpt-wecom .

FROM alpine:3.16

ARG TZ="Asia/Shanghai"

ENV TZ ${TZ}

RUN mkdir /app && apk upgrade \
&& apk add bash tzdata \
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo ${TZ} > /etc/timezone

WORKDIR /app
COPY --from=builder /app/ .
RUN chmod +x chatgpt-wecom && cp config.example.yml config.yml

CMD ./chatgpt-wecom
Loading

0 comments on commit b5bef18

Please sign in to comment.