Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
executable24 authored Mar 16, 2024
0 parents commit 10723ed
Show file tree
Hide file tree
Showing 9 changed files with 973 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/repo/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 %ACTOR%

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions .github/repo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# %NAME%

[![Build](https://github.com/%REPOSITORY%/actions/workflows/generate.yml/badge.svg)](https://github.com/%REPOSITORY%/actions/workflows/generate.yml)

%ACTOR%'s navigation site, generated by [gena](https://github.com/x1ah/gena)

Site address: https://%ACTOR%.github.io/%NAME%/
39 changes: 39 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
push:
branches:
- gh-pages
paths:
- 'config.yml'

permissions: write-all

name: Generate index.html
jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '1.16'
- name: Checkout code
uses: actions/checkout@v2

- name: Generate
run: |
go get -u github.com/x1ah/gena/cmd/gena
gena -c config.yml 1> index.html
# Commit generated files
- name: Commit files
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "Update site"
# Push changes
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
64 changes: 64 additions & 0 deletions .github/workflows/init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Template Cleanup
on:
push:
branches:
- gh-pages

permissions: write-all

jobs:

# Run cleaning process only if workflow is triggered by the other repository.
template-cleanup:
name: Template Cleanup
runs-on: ubuntu-latest
if: github.event.repository.name != 'gena-template'
steps:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v2

# Cleanup project
- name: Cleanup
run: |
# Prepare variables
NAME="${GITHUB_REPOSITORY##*/}"
ACTOR=$(echo $GITHUB_ACTOR | tr '[:upper:]' '[:lower:]')
SAFE_NAME=$(echo $NAME | sed 's/[- ]/_/g' | sed 's/[^a-zA-Z0-9_]//g' | tr '[:upper:]' '[:lower:]')
SAFE_ACTOR=$(echo $ACTOR | sed 's/[- ]/_/g' | sed 's/[^a-zA-Z0-9_]//g' | tr '[:upper:]' '[:lower:]')
# Replace placeholders
find . -type f -not -path '*/.git/*' -exec sed -i "s/%NAME%/$NAME/g" {} +
find . -type f -not -path '*/.git/*' -exec sed -i "s/%ACTOR%/$ACTOR/g" {} +
find . -type f -not -path '*/.git/*' -exec sed -i "s/%SAFE_NAME%/$SAFE_NAME/g" {} +
find . -type f -not -path '*/.git/*' -exec sed -i "s/%REPOSITORY%/${GITHUB_REPOSITORY/\//\\/}/g" {} +
# Move content
cat .github/repo/README.md > README.md
cat .github/repo/LICENSE > LICENSE
# Cleanup
rm -rf \
.github/repo \
.github/workflows/init.yml \
README_EN.md \
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '1.16'
- name: Install gena
run: |
go get -u github.com/x1ah/gena/cmd/gena
gena -c config.yml > index.html
# Commit modified files
- name: Commit files
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "Init project"
# Push changes
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# 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/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 x1ah

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# gena-template

[gena](https://github.com/x1ah/gena) 导航网站生成模板,零依赖,自动部署。 | [English Document](https://github.com/x1ah/gena-template/blob/master/README_EN.md)

Demo: [when.run/nav](https://when.run/nav/)

![image](https://user-images.githubusercontent.com/14919255/115016835-3395f900-9ee8-11eb-90d7-5ed816f59872.png)
![image](https://user-images.githubusercontent.com/14919255/116776971-3b37cf00-aa9e-11eb-9456-83a79a6e166d.png)


## 使用方法

只需要点击仓库右上方 [<kbd>Use this template</kbd>](https://github.com/x1ah/gena-template/generate) 按钮

![image](https://user-images.githubusercontent.com/14919255/114821045-8ee5bf80-9df2-11eb-9d17-d617c946b65e.png)

并填写仓库名,创建项目之后,等待几分钟,刷新刚创建的仓库,访问 README 中的地址(`https://<github-id>.github.io/<repo>/`) 查看效果

## 更新网站内容

按格式修改项目根目录里的 `config.yml` 配置文件,并提交,等待几分钟后访问 `https://<github-id>.github.io/<repo>/` 查看效果
20 changes: 20 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# gena-template

[gena](https://github.com/x1ah/gena) navigation site template | [中文文档](https://github.com/x1ah/gena-template/blob/master/README_CN.md)

Demo: [when.run/nav](https://when.run/nav/)

![image](https://user-images.githubusercontent.com/14919255/115016835-3395f900-9ee8-11eb-90d7-5ed816f59872.png)

## Getting started

All you have to do is click the <kbd>Use this template</kbd> button.

![image](https://user-images.githubusercontent.com/14919255/114821045-8ee5bf80-9df2-11eb-9d17-d617c946b65e.png)

After using the template to create your project, the generate workflow will be triggered to generate your website, that available at `https://you-name.github.io/<repo>/`

## Update site

Update `config.yml` in your project. workflow will regenerate website in a few minutes

Loading

0 comments on commit 10723ed

Please sign in to comment.