-
Notifications
You must be signed in to change notification settings - Fork 18
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
0 parents
commit 365daec
Showing
25 changed files
with
2,129 additions
and
0 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,41 @@ | ||
# 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: | ||
- 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 |
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,84 @@ | ||
# 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@v3 | ||
|
||
- name: Inject slug/short variables | ||
uses: rlespinasse/github-slug-action@v4 | ||
|
||
- 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@v2 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Available platforms | ||
run: echo ${{ steps.buildx.outputs.platforms }} | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: eryajf | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
# 所需要的体系结构,可以在 Available platforms 步骤中获取所有的可用架构 | ||
platforms: linux/arm64,linux/amd64 | ||
# 镜像推送时间 | ||
push: ${{ github.event_name != 'pull_request' }} | ||
# 给清单打上多个标签 | ||
tags: | | ||
eryajf/cloud_dns_exporter:latest | ||
eryajf/cloud_dns_exporter:${{ steps.date.outputs.today }} | ||
# 镜像推送到 阿里云仓库 | ||
- name: Login to the Ali Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: registry.cn-hangzhou.aliyuncs.com | ||
username: eryajf | ||
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/eryajf/cloud_dns_exporter:${{ env.GITHUB_REF_NAME }} | ||
registry.cn-hangzhou.aliyuncs.com/eryajf/cloud_dns_exporter: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,32 @@ | ||
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 | ||
- name: Inject slug/short variables | ||
uses: rlespinasse/github-slug-action@v4 | ||
- uses: wangyoucao577/go-release-action@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} # 一个默认的变量,用来实现往 Release 中添加文件 | ||
goos: ${{ matrix.goos }} | ||
goarch: ${{ matrix.goarch }} | ||
retry: 10 | ||
overwrite: true | ||
build_command: "make" | ||
build_flags: "build VERSION=${{ env.GITHUB_REF_NAME }}" | ||
goversion: 1.22 # 可以指定编译使用的 Golang 版本 | ||
binary_name: "cloud_dns_exporter" # 可以指定二进制文件的名称 | ||
extra_files: config.example.yaml LICENSE README.md # 需要包含的额外文件 |
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,46 @@ | ||
name: Lint Check | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- release/** | ||
pull_request: | ||
branches: | ||
- main | ||
- release/** | ||
permissions: read-all | ||
jobs: | ||
gofmt: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Go Environment | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.22.4' | ||
- name: Run gofmt Check | ||
working-directory: ./ | ||
run: | | ||
diffs=`gofmt -l .` | ||
if [[ -n $diffs ]]; then | ||
echo "Files are not formatted by gofmt:" | ||
echo $diffs | ||
exit 1 | ||
fi | ||
golint: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Go Environment | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.22.4' | ||
- name: Download golangci-lint | ||
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.57.2 | ||
- name: Run Golang Linters | ||
working-directory: ./ | ||
run: | | ||
PATH=${PATH}:$(go env GOPATH)/bin make lint |
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,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.ACCESS_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,26 @@ | ||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
tmp | ||
|
||
# Config file | ||
config.yaml | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
cloud_dns_exporter | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work |
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,9 @@ | ||
# 贡献者指南 | ||
|
||
欢迎反馈、bug 报告和拉取请求,可点击[issue](https://github.com/eryajf/cloud_dns_exporter/issues) 提交. | ||
|
||
如果你是第一次进行 GitHub 协作,可参阅: [协同开发流程](https://howtosos.eryajf.net/HowToStartOpenSource/01-basic-content/03-collaborative-development-process.html) | ||
|
||
1. 项目使用`golangci-lint`进行检测,提交 pr 之前请在本地执行 `make lint` 并通过。 | ||
|
||
2. 如非必要,尽可能谨慎新增配置文件,以免造成升级时产生意料之外的问题。 |
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 registry.cn-hangzhou.aliyuncs.com/eryajf/golang:1.22.2-alpine3.19 AS builder | ||
|
||
WORKDIR /app | ||
|
||
ENV GOPROXY https://goproxy.io | ||
|
||
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories \ | ||
&& apk upgrade && apk add --no-cache --virtual .build-deps \ | ||
ca-certificates gcc g++ curl upx git make | ||
|
||
ADD . . | ||
|
||
RUN make build-linux && upx -9 cloud_dns_exporter | ||
|
||
FROM registry.cn-hangzhou.aliyuncs.com/eryajf/alpine:3.19 | ||
|
||
WORKDIR /app | ||
|
||
LABEL maintainer eryajf | ||
|
||
COPY --from=builder /app/config.example.yaml config.yaml | ||
COPY --from=builder /app/cloud_dns_exporter . | ||
|
||
EXPOSE 21798 | ||
|
||
RUN chmod +x /app/cloud_dns_exporter | ||
|
||
CMD [ "/app/cloud_dns_exporter" ] |
Oops, something went wrong.