-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
334 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: Bug report | ||
about: 提交bug以改进项目~ | ||
title: '' | ||
labels: bug | ||
assignees: 404name | ||
|
||
--- | ||
|
||
**描述BUG情况** | ||
A clear and concise description of what the bug is. | ||
|
||
**BUG复现步骤** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**正常期望得到的结果** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**截图** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**运行环境** | ||
- 平台: [e.g. mac/win] | ||
- 项目版本: [V0.x.x] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: 提交建议/需求 以改进项目 | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: build docker image | ||
|
||
on: | ||
release: | ||
types: [created] | ||
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: Get current date | ||
id: date | ||
run: echo "::set-output name=today::$(date +'%Y-%m-%d_%H-%M')" | ||
|
||
- 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: Determine tag | ||
id: tag | ||
run: | | ||
if [ -n "${{ github.event.release.tag_name }}" ]; then | ||
echo "::set-output name=tag::${{ github.event.release.tag_name }}" | ||
else | ||
echo "::set-output name=tag::${{ steps.date.outputs.today }}" | ||
fi | ||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: | | ||
404name/image-upload-portal:${{ steps.tag.outputs.tag }} | ||
404name/image-upload-portal:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: build-go-binary | ||
|
||
on: | ||
release: | ||
types: [created] # 表示在创建新的 Release 时触发 | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
env: | ||
flags: '' | ||
steps: | ||
# 1. 检出代码 | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# 2. 设置 Go 环境 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.21 | ||
cache: true | ||
|
||
# 3. 运行 GoReleaser | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --clean ${{ env.flags }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_SET_TOKEN }} | ||
|
||
# 4. 安装 GitHub CLI | ||
- name: Install GitHub CLI | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y gh | ||
# 5. 定义镜像列表并拉取、推送镜像 | ||
- name: Pull and push images to Release | ||
run: | | ||
# 定义镜像列表 | ||
images=" | ||
nginx:latest | ||
mysql:5.7 | ||
jmalloc/echo-server:latest | ||
" | ||
# 逐行处理镜像列表 | ||
echo "$images" | while read -r image; do | ||
if [ -n "$image" ]; then | ||
echo "Pulling and pushing image: $image" | ||
# 生成带前缀的文件名 | ||
filename="offline-image-$(echo "$image" | tr ':/' '-').tar" | ||
# 拉取镜像并保存为临时文件 | ||
docker pull "$image" | ||
docker save -o "$filename" "$image" | ||
# 上传临时文件到 Release | ||
gh release upload ${{ github.event.release.tag_name }} "$filename" --clobber | ||
# 删除临时文件 | ||
rm "$filename" | ||
fi | ||
done | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_SET_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
project_name: image-upload-portal | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
|
||
builds: | ||
- binary: image-upload-portal | ||
main: . | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
goarch: | ||
- amd64 | ||
- arm | ||
- arm64 | ||
ignore: | ||
- goos: windows | ||
goarch: arm | ||
- goos: windows | ||
goarch: arm64 | ||
|
||
# checksum: | ||
# name_template: "checksums.txt" | ||
|
||
archives: | ||
- name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- .Version }}_ | ||
{{- if eq .Os "darwin" }}macos_ | ||
{{- else }}{{ .Os }}_{{ end }} | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else if eq .Arch "arm64" }}aarch64 | ||
{{- else if eq .Arch "arm" }}armv{{ .Arm }} | ||
{{- else }}{{ .Arch }}{{ end }} | ||
wrap_in_directory: true | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
builds_info: | ||
group: root | ||
owner: root | ||
files: | ||
- README.md | ||
- LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# 第一阶段:构建阶段 | ||
FROM golang:1.22-alpine AS builder | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 复制项目文件到容器中(排除 .dockerignore 中的内容) | ||
COPY . . | ||
|
||
# 构建应用并清理缓存 | ||
RUN go build -o /app/main . && \ | ||
rm -rf /go/pkg/mod /root/.cache/go-build | ||
|
||
# 第二阶段:运行阶段 | ||
FROM alpine:latest | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 从构建阶段复制构建好的二进制文件 | ||
COPY --from=builder /app/main /app/main | ||
|
||
# 设置环境变量 | ||
ENV ROOT=. | ||
ENV TMP_DIR=tmp | ||
|
||
# 运行应用 | ||
CMD ["./main", "server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,4 @@ ENV ROOT=. | |
ENV TMP_DIR=tmp | ||
|
||
# 运行应用 | ||
CMD ["./main", "server"] | ||
CMD ["./main", "server"] |
Oops, something went wrong.