Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hiifong committed Jul 22, 2023
0 parents commit 4e49beb
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy Jekyll with GitHub Pages dependencies preinstalled

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
paths-ignore:
- 'zones/**'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v2

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
24 changes: 24 additions & 0 deletions .github/workflows/update-dns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Update DNS

on:
push:
branches: [ main ]
paths:
- 'zones/**'


jobs:
depoly:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 5

- name: Run a multi-line script
run: |
export CF_API_EMAIL=${{ secrets.CF_API_EMAIL }}
export CF_API_KEY=${{ secrets.CF_API_KEY }}
bash install-flarectl.sh
bash depoly.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
flarectl
Binary file added Alipay.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
biu-x.org
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# `biu-x.org`子域名申请
## 申请流程

- Fork 本项目
- 域名信息添加
在项目下[zones](./zones)`biu-x.org`下,按照`#NAME, TYPE, CONTENT`格式添加,一行一条记录
- 提交 Pull Request
- 等待审核,确认后部署

## 鸣谢

感谢 [Cloudflare](https://www.cloudflare.com/) 提供的优质 DNS 服务及相关服务。

感谢 [Vercel](https://vercel.com) 提供优质的主机服务。

感谢 [XuPeiYao](https://github.com/XuPeiYao/cloudflare-dns-update-sample) 提供的脚本。

如果您对本项目感兴趣,可以通过以下方式支持我:

- 关注我的 Github 账号:[@hiifong](https://github.com/hiifong) [![github](https://img.shields.io/github/followers/hiifong.svg?style=social&label=Followers)](https://github.com/hiifong)
- 扫码打赏
- 微信
<img src="./WeChat.png" width="200px" height="200px" />
- 支付宝
<img src="./Alipay.jpg" width="200px" height="200px" />
Binary file added WeChat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions depoly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# list all zones
for zone in $(ls ./zones)
do
# Delete domain
# Ignore all config line starting with '#'
while IFS=, read -r name type content
do [[ $name =~ (^#.*) ]] && continue
name="$(echo -e "${name}" | tr -d '[[:space:]]')"
type="$(echo -e "${type}" | tr -d '[[:space:]]')"
content="$(echo -e "${content}" | tr -d '[[:space:]]')"

if [ "$name" = "" ]
then
continue
fi

while IFS="|" read -r id type name content proxied ttl
do
id="$(echo -e "${id}" | tr -d '[[:space:]]')"
echo Remove $id $name
./flarectl dns delete --zone=$zone --id=$id
done < <(./flarectl dns list --zone $zone --name $name.$zone --type $type | grep -P "\s*[a-z0-9]+");
done < <(git --no-pager diff --ignore-space-at-eol HEAD~1 -- ./zones/$zone | grep -P "^[\-]([^,]+,){2}[^,]+" | cut -c 2-);

# Add domain
# Ignore all config line starting with '#'
while IFS=, read -r name type content
do [[ $name =~ (^#.*) ]] && continue
name="$(echo -e "${name}" | tr -d '[[:space:]]')"
type="$(echo -e "${type}" | tr -d '[[:space:]]')"
content="$(echo -e "${content}" | tr -d '[[:space:]]')"

if [ "$name" = "" ]
then
continue
fi

./flarectl dns create-or-update --zone=$zone --name=$name --content=$content --type=$type;
done < <(git --no-pager diff --ignore-space-at-eol HEAD~1 -- ./zones/$zone | grep -P "^[\+]([^,]+,){2}[^,]+" | cut -c 2-);
done
3 changes: 3 additions & 0 deletions install-flarectl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
wget https://github.com/cloudflare/cloudflare-go/releases/download/v0.45.0/flarectl_0.45.0_linux_amd64.tar.xz
tar -xf flarectl_0.45.0_linux_amd64.tar.xz
2 changes: 2 additions & 0 deletions zones/biu-x.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#NAME, TYPE, CONTENT
hiifong,CNAME,cname.vercel-dns.com

0 comments on commit 4e49beb

Please sign in to comment.