您在github上可能會用到
而當您看別人的專案時,有其是Issues,你會發現,當要新增時可能會有一些選項讓您填選
例如:
而這些東西又是怎麼建立出來的呢?
要建立這些東西有兩個途徑可以選擇
Settings → (往下滑) → Features
→ ☑ Issues
→ 點擊 Set up templates
點擊上方圖片的位置,接著當引導就能順利完成了!
我個人是推薦這個方法
不管你是用UI還是這個方法,最後都會生成檔案在您的.github
目錄下
結構,如下
CONTRIBUTING.md # issue
SECURITY.md # Security中會看到的東西
.github 📂
- SUPPORT.md # 發問issue時會提醒使用者
- PULL_REQUEST_TEMPLATE.md # 建立pull request時的樣板
- dependabot.yml
- 📂 workflows (裡面放的就是自己建立的yml,看你有多少workflows就建立多少個,高興就好!)
- stale.yml # 這是一個人家寫好的bot,可以自動地把一些issues做歸類,而不靠人工處理
- ...
- *.yml
- 📂 ISSUE_TEMPLATE
- config.yml # Issues中可以有其他連結,可以透過點擊Open即可打開某些連結,都可以在這個檔案設定
- bug_report.md # 自定義的issue樣板
- feature_request.md # 自定義的issue樣板
在發問issues時,右偏上的位置會出現的連結,提示您如果要做貢獻的時候該注意哪些事項
您可以在根目錄
中新增SECURITY.md的檔案,並放上您要的內容,就會呈現出Security的內容。
例如右邊的範例:如果有問題可以寄信,然後48小時之內會回覆…
📙 這個檔案也會出現在Issues之中(H3會是看到中的標題文字),其中按鈕的說明會是:「
View policy
」。
## Security Policy
### Reporting a Vulnerability
Please report (suspected) security vulnerabilities to **[bjorn.erik.pedersen@gmail.com](mailto:bjorn.erik.pedersen@gmail.com)**. You will receive a response from us within 48 hours. If we can confirm the issue, we will release a patch as soon as possible depending on the complexity of the issue but historically within days.
Also see [Hugo's Security Model](https://gohugo.io/about/security-model/).
如果您第一次在該站發問issues,security也會出現在右邊來提醒
發問issue時會提醒使用者
建立完之後,當有pull request的請求,就會自動帶入此樣板
- [ ] **Bug fix?**
- [ ] **New Feature?**
**Resolve an issue?**
<!-- Please prefix each issue number with "Fix #" (e.g. Fix #200) -->
**Example(s)?**
<!-- Love bootstrap-table? Please consider supporting our collective:
👉 https://opencollective.com/bootstrap-table/donate -->
👆 以上範例來至bootstrap-table.PULL_REQUEST_TEMPLATE.md
Dependabot 可以自動維护您的倉庫的依賴項。
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
總之您可以用它來達到CI/CD的效果。
而workflows可以在actions中建立,如下圖:
📙 了解更多關於Github Actions
您可以在這邊挑選一些人家寫好的樣板,幾乎每一種語言都有人寫該樣板,用來測試發佈出去時可以正常運作
所以你可以挑你要的之後再做更改。
我這邊介紹一些我覺得目前對我比較有用,以及一些特別的workflow
這是我的其中一個腳本,主要是使用golang來爬取文檔的資料,檢查資料有沒有輸入錯誤。
當然如果您願意可以一次建立很多workflow,反正每一個workflow都是獨立的,而且每一個都有各自的觸發程序。
on: [push, pull_request] # 觸發條件,當push或者pull_request時都會觸發 // 也能用created, edited
name: Test # workflow的名稱
branches: # 要作用到那些分支
- main
- release
jobs: # 可以一次放很多job
test: # job名稱
env: # 環境變數設定
GOPROXY: https://proxy.golang.org
GO111MODULE: on
strategy: # 讓您設置變數,用$來存取
matrix: # ${{matrix. }}
go-version: [1.16.x] # ${{ matrix.go-version }}
os: [ubuntu-latest, macos-latest, windows-latest] # ${{ matrix.os }}
runs-on: ${{ matrix.os }} # 要在哪些作業系統運行,他會依次的傳遞每個項目給steps,也就是能在steps中,使用matrix.os得到目前是位於哪一個平台
steps:
- name: Install Go
# Setup Go environment: https://github.com/marketplace/actions/setup-go-environment
uses: actions/setup-go@37335c7bb261b353407cff977110895fa0b4f7d8 # 這邊是引用其他人寫好的github action: https://github.com/actions/setup-go
with: # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepswith
go-version: ${{ matrix.go-version }} # INPUT_GO-VERSION
# 注意! a step cannot have both the `uses` and `run` keys 有with就不能再寫run了
- name: Install Ruby
uses: actions/setup-ruby@5f29a1cd8dfebf420691c4c9a0e832e2fae5a526
with:
ruby-version: '2.7'
- name: Install Python
uses: actions/setup-python@3105fb18c05ddd93efea5f9e0bef7a03a6e9e7df
with:
python-version: '3.x'
- name: Install Mage
run: go get github.com/magefile/mage@07afc7d24f4d6d6442305d49552f04fbda5ccb3e
- name: Install asciidoctor
uses: reitzig/actions-asciidoctor@7570212ae20b63653481675fb1ff62d1073632b0
- name: Checkout code
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Install docutils
run: |
pip install docutils
rst2html.py --version
- if: matrix.os == 'ubuntu-latest'
name: Install pandoc on Linux
run: |
sudo apt-get update -y
sudo apt-get install -y pandoc
- if: matrix.os == 'macos-latest'
run: |
brew install pandoc
- if: matrix.os == 'windows-latest'
run: |
choco install pandoc
- run: pandoc -v
- if: matrix.os == 'ubuntu-latest'
name: Install dart-sass-embedded Linux
run: |
curl -LJO https://github.com/sass/dart-sass-embedded/releases/download/1.0.0-beta.6/sass_embedded-1.0.0-beta.6-linux-x64.tar.gz;
echo "04fc1e5e28d29a4585a701941b6dace56771d94bfbe7f9e4db28d24417ceeec3 sass_embedded-1.0.0-beta.6-linux-x64.tar.gz" | sha256sum -c;
tar -xvf sass_embedded-1.0.0-beta.6-linux-x64.tar.gz;
echo "$GITHUB_WORKSPACE/sass_embedded/" >> $GITHUB_PATH
- if: matrix.os == 'macos-latest'
name: Install dart-sass-embedded MacOS
run: |
curl -LJO https://github.com/sass/dart-sass-embedded/releases/download/1.0.0-beta.6/sass_embedded-1.0.0-beta.6-macos-x64.tar.gz;
echo "b3b984675a9b04aa22f6f2302dda4191b507ac2ca124467db2dfe7e58e72fbad sass_embedded-1.0.0-beta.6-macos-x64.tar.gz" | shasum -a 256 -c;
tar -xvf sass_embedded-1.0.0-beta.6-macos-x64.tar.gz;
echo "$GITHUB_WORKSPACE/sass_embedded/" >> $GITHUB_PATH
- if: matrix.os == 'windows-latest'
name: Install dart-sass-embedded Windows
run: |
curl -LJO https://github.com/sass/dart-sass-embedded/releases/download/1.0.0-beta.6/sass_embedded-1.0.0-beta.6-windows-x64.zip;
echo "6ae442129dbb3334bc21ef851261da6c0c1b560da790ca2e1350871d00ab816d sass_embedded-1.0.0-beta.6-windows-x64.zip" | sha256sum -c;
unzip sass_embedded-1.0.0-beta.6-windows-x64.zip;
echo "$env:GITHUB_WORKSPACE/sass_embedded/" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf-8 -Append
- name: Test
run: |
mage -v test
mage -v check;
- name: Build Docs
env:
HUGO_BUILD_TAGS: extended
HUGO_TIMEOUT: 31000
HUGO_IGNOREERRORS: error-remote-getjson
run: |
mage -v hugo
./hugo -s docs/
./hugo --renderToMemory -s docs/
name
: 使用者在UI上面看到的標題名稱
about
: 標題名稱下方的description
title
: 使用者回答問題上的標題,標題的預先填入內容
labels
: 有多個標籤的時候用「,
」分開,支持emoji (主要是md他用的是goldmark,這個就有支持),但我個人建議盡量用unicode emoji
❗ 標籤要生效則必須這些標籤要已存在,當然您也可以先建立,之後再去補標籤。總之如果這些標籤沒有存在,最後使用該issue的時候就不會自動加上這些標籤
assignees
: 打上使用者的名稱即可
註記方式使用yml,可以讓他知道標籤的分類等等
而因為使用者看到的是row-data,所以有些東西如果您只是要提醒,可以像第8列那樣寫註解即可
最後github的markdown是有支援HTML的,所以可以直接像12-14列一樣寫上HTML的語法
1---
2name: 'Bug report'
3title: ''
4labels: 'bug, unsolved 🙋♀️'
5assignees: ''
6about: Create a report to help us improve
7---
8
9<!-- Please answer these questions before submitting your issue. Thanks! -->
10
11### What version of Hugo are you using (`hugo version`)?
12
13<pre>
14$ hugo version
15</pre>
16
17### Does this issue reproduce with the latest release?
範本2
---
name: Bug 回報
about: 提交bug幫助我們修復
title: "[BUG]"
labels: "🐛bug, 🀄zh"
assignees: "Carson"
---
### bug 描述 <!--详细地描述 bug,让大家都能理解-->
### 复现步骤 <!--清晰描述复现步骤,让别人也能看到问题-->
### 期望结果 <!--描述你原本期望看到的结果-->
### 复现代码 <!--提供可复现的代码,倉庫,或线上示例-->
### 版本信息:
- version: <!--e.g. 1.0.0-->
- OS <!--e.g. mac OS-->
### 其他信息 <!--如截图等其他信息可以贴在这里-->
這個檔案會出現在Issues的Open之中
blank_issues_enabled: false # 如果設定為false,就表示使用者不能隨意的新增自定義的issue # option allows you to show or hide the Create a blank issue choice when users select New issue
contact_links:
- name: Support
url: https://discourse.gohugo.io/
about: Please do not use Github for support requests. Visit https://discourse.gohugo.io for support!
請參考:
Qualifier | Example |
---|---|
in:title | warning in:title matches issues with “warning” in their title. |
in:body | error in:title,body matches issues with “error” in their title or body. |
in:comments | shipit in:comments matches issues mentioning “shipit” in their comments. |
issue: 3 4 5 | 搜尋#3, #4, #5 |
✨ error in:title,body,comments | matches issues with “error” in their title, body, comments. |
有一些常用的統計,或者項目搜尋一下人家已經都弄好了,如果萬不得已可以自己生成,例如
<a href="https://pypi.org/project/console-color/">
<img src="https://img.shields.io/static/v1?&style=plastic&logo=pypi&label=App&message=console-color&color=00FFFF"/></a>
plastic
, social
, flat-square
, flat
, for-the-badge
} 基本上我覺得plastic是最好看的,比較圓滑github
, pypi
, go
, javascript
, d3.js
} 也用data-uri,例如: ?logo=data:image/png;base64,…
?link=http://left&link=http://right
但不適用於markdown的樣子,建議還是用a來幫忙呈現的結果如下
您可能會想,Github上有沒有像是shields.io提供一些圖片讓使用者顯示一些統計資料呢?
答案是有的,可以利用:
這邊先丟出一些結果以及語法給您參考:
<a href="https://github.com/CarsonSlovoka">
<img src="https://github-readme-stats.vercel.app/api?username=CarsonSlovoka&show_icons=true&count_private=true&theme=highcontrast" alt="CarsonSlovoka's github stats" />
<img src="https://github-readme-stats.vercel.app/api/top-langs/?username=CarsonSlovoka&theme=highcontrast&layout=compact" alt="CarsonSlovoka's github top languages">
<img src="https://github-readme-stats.vercel.app/api/top-langs?username=CarsonSlovoka&langs_count=8&theme=highcontrast" alt="TOP Langs">
</a>
👆複製下來接著把CarsonSlovoka
改成您自己的名稱即可呈現出您的Github資訊,類似下圖
以下是另一種風格:
[](https://github.com/CarsonSlovoka)
👇接下來我們就來深入探討github-readme-stats的更多用法
萬變不如其宗:
以上連結有提供api,讓您直接調用連結就能顯示一些統計數據
如果您想探索更多請自行點擊👉 anuraghazra/github-readme-stats 去探索
我把我覺得實用的整理如下
API名稱 | 描述 | endpoint | 範例 | demo |
---|---|---|---|---|
stats card (預設) | 統計表 | api? | https://github-readme-stats.vercel.app/api/?username=anuraghazra&repo=github-readme-stats | |
pins | 釘選小卡片 | api/pin? | https://github-readme-stats.vercel.app/api/pin?username=anuraghazra&repo=github-readme-stats | |
top lang | 正常版本 | api/top-langs? | https://github-readme-stats.vercel.app/api/top-langs?username=anuraghazra&repo=github-readme-stats | |
top lang | compress版本 | api/top-langs?…&layout=compact | https://github-readme-stats.vercel.app/api/top-langs?username=anuraghazra&repo=github-readme-stats&layout=compact | |
wakatime | api/wakatime? | https://github-readme-stats.vercel.app/api/wakatime?username=willianrod |
此外它有提供一些可選項,這些可選項可以搭配API來使用
名稱 | 型別 | 說明 |
---|---|---|
themes | string | 目前一共有8類可以選擇,如下: dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula |
username | string | 您的github使用者名稱 |
repo | string | 您的專案名 |
show_icons | bool | |
locale | 可以設定語言: cn, de, es, etc. | |
border_radius | 卡片border的圓滑度 | |
bg_color | ||
icon_color | ||
text_color | ||
title_color | ||
hide_border | bool | |
★ count_private | bool | 這個很有用,可以把private的專案也考量近來 |
功能 | 語法 | 型別 | 範例 | 附註 |
---|---|---|---|---|
Exclude individual repositories | exclude_repo | []string | &exclude_repo=proj1,proj2,proj3.github.io | |
Hide individual languages | hide | []string | &hide=javascript,html | |
Show more languages | langs_count | int | &langs_count=8 | 1~10(預設5) |
Compact Language Card Layout | layout | string | &layout=compact | 擠壓在一塊呈現 |
👉點我 參考更多內容!