Skip to content

Commit

Permalink
Chore: 更新 deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Nov 26, 2024
1 parent fc3b7d7 commit 9663864
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 94 deletions.
46 changes: 34 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,52 @@ on:
types:
- completed
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:
Actions-Hugo-Deploy:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
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@v3
with:
hugo-version: latest
extended: true

- name: Build
- name: Hugo build
run: hugo --gc --minify --logLevel info

- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# See https://github.com/JamesIves/github-pages-deploy-action#configuration-
branch: gh-pages
folder: public
clean: true
single-commit: true
# Upload only the public directory
path: './public'

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ public/
resources/

.hugo_build.lock
_vendor
jsconfig.json
18 changes: 14 additions & 4 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ For a complete quick start, see this [page](https://fixit.lruihao.cn/documentati
git clone --recursive https://github.com/<your_name>/<your_blog_repo>.git
```

> [!TIP]
> The repository name determines your GitHub Pages URL, for example:
>
> | Repository Name | GitHub Pages |
> | :--- | :--- |
> | `<your_name>.github.io` | `https://<your_name>.github.io/` |
> | `blog` | `https://<your_name>.github.io/blog/` |

### Launching the Site

```bash
Expand All @@ -60,11 +68,13 @@ hugo

### Deploy to GitHub Pages

1. Head to Setting => Actions => General => Workflow permissions => Check "Read and write permissions".
2. Manually run Workflow: Actions => Hugo build and deploy => Click Run workflow button.
3. GitHub Pages settings: Setting => Pages => Source: Deploy from a branch => Branch: `gh-pages` => Save.
> [!NOTE]
> You may have noticed that the first automatic deployment of GitHub Actions after the template initialization failed. This is because you have not configured Workflow permissions and GitHub Pages.

> Only need to manually run the Workflow the first time you deploy, and it will be automatically deployed every time you push to the `main` branch.
1. Head to Setting => Actions => General => Workflow permissions => Check "Read and write permissions".
2. GitHub Pages settings: Setting => Pages => Source: GitHub Actions.
3. Modify `config/_default/hugo.toml` file `baseURL` to your site URL.
4. Commit the changes from the previous step to the `main` branch, and GitHub Actions will automatically build and deploy the site to GitHub Pages.

### Update theme

Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
git clone --recursive https://github.com/<your_name>/<your_blog_repo>.git
```

> [!TIP]
> 仓库名决定了你的 GitHub Pages URL,例如:
>
> | 仓库名 | GitHub Pages |
> | :--- | :--- |
> | `<your_name>.github.io` | `https://<your_name>.github.io/` |
> | `blog` | `https://<your_name>.github.io/blog/` |

### 启动站点

```bash
Expand All @@ -60,11 +68,13 @@ hugo

### 部署到 GitHub Pages

1. 转到 Setting => Actions => General => Workflow permissions => 选中 "Read and write permissions"
2. 手动运行 Workflow: Actions => Hugo build and deploy => 点击 Run workflow 按钮。
3. GitHub Pages 设置:Setting => Pages => Source: Deploy from a branch => Branch: `gh-pages` => Save。
> [!NOTE]
> 聪明的你可能已经注意到,模板初始化后的第一次 GitHub Actions 自动部署失败了。这是因为你还没有配置 Workflow 权限和 GitHub Pages。

> 只有第一次部署时需要手动运行 Workflow,之后每次推送到 `main` 分支都会自动部署。
1. 转到 Setting => Actions => General => Workflow permissions => 选中 "Read and write permissions"
2. GitHub Pages 设置:Setting => Pages => Source: GitHub Actions。
3. 修改 `config/_default/hugo.toml` 文件中的 `baseURL` 为你的站点 URL。
4. 提交上一步的修改到 `main` 分支,GitHub Actions 将自动打包并部署站点到 GitHub Pages。

### 更新主题

Expand Down
75 changes: 2 additions & 73 deletions content/posts/hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,90 +6,19 @@ tags:
- FixIt
categories:
- hello
code:
maxShownLines: 11
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---

Welcome to Hugo FixIt! This is your very first post.

<!--more-->

## Documentation

Head to the documentation page linked below for a complete guidence to get started with the [FixIt](https://github.com/hugo-fixit/FixIt) theme.

{{< fixit-docs-bookmark >}}

## Quick Start

For a complete quick start, see this [page](https://fixit.lruihao.cn/documentation/getting-started/).

### Prerequisites

[Hugo](https://gohugo.io/installation/): >= 0.132.0 (extended version)

### Use this Template

1. Click [**Use this template**](https://github.com/hugo-fixit/hugo-fixit-starter1/generate), and create your repository on GitHub.

<img width="913" alt="image" src="https://github.com/hugo-fixit/hugo-fixit-starter1/assets/33419593/d5fbd940-3ffd-4750-b1e6-4e87b50b0696">

2. Once the repository is created, just clone and enjoy it!

```bash
# Clone with your own repository url
git clone --recursive https://github.com/<your_name>/<your_blog_repo>.git
```

### Launching the Site

```bash
# Development environment
hugo server
# Production environment
hugo server -e production
```

### Build the Site

When your site is ready to deploy, run the following command:

```bash
hugo
```

### Deploy to GitHub Pages

1. Head to Setting => Actions => General => Workflow permissions => Check "Read and write permissions".
2. Manually run Workflow: Actions => Hugo build and deploy => Click Run workflow button.
3. GitHub Pages settings: Setting => Pages => Source: Deploy from a branch => Branch: `gh-pages` => Save.

> Only need to manually run the Workflow the first time you deploy, and it will be automatically deployed every time you push to the `main` branch.

### Update theme

Afterwards you can upgrade the theme with the following command:

```bash
# Update theme manually
git submodule update --remote --merge themes/FixIt
```

<details>
<summary>Start via NPM script</summary>

```bash
# build the blog
npm run build
# run a local debugging server with watch
npm run server
# run a local debugging server in production environment
npm run server:production
# update theme submodules
npm run update:theme
```

</details>

## Feedback

Whether it's questions, ideas, bugs or pull requests, all feedback is welcome!
Expand Down
2 changes: 1 addition & 1 deletion themes/shortcode-docs-bookmark

0 comments on commit 9663864

Please sign in to comment.