步骤
- 设置好cloudflare的workers
- Fork这个库: https://github.com/ffreemt/ttw-blog
- 设置库的Secrets:
- Name:
CF_API_TOKEN - Value:
~/.wrangler/config/default.toml或%userprofile%\.wrangler\conf ig\default.toml里的api_token或从Cloudflare上取。
- Name:
- 改
config.toml文件里的东西及content目录的文件。 git add . && git commit -m "update" && git push
For self
To set name = "blog" in wrangler.toml:
wrangler init --site blog
# add `account_id` and bucket = "public"
deploy.yml in `.github/workflows
name: Deploy to CF Workers
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@v2
- name: Install Hugo
run: sudo snap install hugo
- name: Build hugo minify gc
run: hugo --minify --gc
- name: Publish
uses: cloudflare/wrangler-action@1.3.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
preCommands: echo "*** pre command ***"
postCommands: |
echo "*** post commands ***"
wrangler publish
echo "******"
For record
- name: Creatte wrangler.toml with name=blog and bucket=public
run: |
wrangler init --site blog
sed -i 's/bucket = ""/bucket = "public"/g' wrangler.toml
sed -i 's/account_id = ""/account_id = "'$CF_API_TOKEN'"/g' wrangler.toml
echo wrangler.toml
- name: config wrangler # run: CF_API_TOKEN=${{ secrets.CF_API_TOKEN }} wrangler publish
References