北极贝

北极贝

Crisp, personal blog

29 Nov 2022

Start My Blog

create site

hugo new site quickstart
cd quickstart
git init
git submodule add https://github.com/knadh/hugo-ink.git themes/ananke
echo "theme = 'hugo-ink'" >> config.toml
hugo server

theme hugo-ink

github action

on: [push]

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      deployments: write
    name: Publish to Cloudflare Pages
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: true # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: "0.101.0"

      - name: Build
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        # If you're changing the branch from main,
        # also change the `main` in `refs/heads/main`
        # below accordingly.
        if: ${{ github.ref == 'refs/heads/main' }}
        with:
          github_token: ${{ secrets.HOGO_GITHUB_TOKEN }}
          publish_dir: ./public

      - name: Publish to Cloudflare Pages
        uses: cloudflare/pages-action@1
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: accountId
          projectName: projectName
          directory: ./public
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}

cloudflare-pages

Generate an API Token

To generate an API token:

  1. Log in to the Cloudflare dashboardOpen external link.
  2. Select My Profile from the dropdown menu of your user icon on the top right of your dashboard.
  3. Select API Tokens > Create Token.
  4. Under Custom Token, select Get started.
  5. Name your API Token in the Token name field.
  6. Under Permissions, select Account, Cloudflare Pages and Edit:
  7. Select Continue to summary > Create Token.

Set up a workflow(github actions)

Create a .github/workflows/pages-deployment.yaml file at the root of your project.

other metheds

Using CircleCI for CI/CD Travis CI for CI/CD