feat(build.yml): add GitHub Actions workflow for building the project

This commit adds a new file `.github/workflows/build.yml` which contains the configuration for a GitHub Actions workflow named "Build". The workflow is triggered on push events to the `main` branch and manually through the workflow_dispatch event.

The workflow consists of two jobs: "Filter" and "Build". The "Filter" job checks for changes in specific files (`package.json` and `assets/**`) and sets an output variable `any_changed` to indicate if any of the files have changed.

The "Build" job is executed if the following conditions are met:
- The workflow is triggered on the `main` branch
- The repository is not a fork
- The "Filter" job has detected changes in the specified files

The steps in the "Build" job include:
- Checking out the repository
- Setting up Hugo with version 0.114.0 and extended mode
- Setting up pnpm version 8
- Getting the pnpm store directory and caching it
- Caching the Hugo resources directory
- Installing dependencies using pnpm
- Building the project using the `pnpm run build` command
- Pushing the built artifacts if the workflow was triggered by a merged pull request
This commit is contained in:
Sped0n
2023-11-04 21:02:43 +08:00
parent 558979285b
commit 8edb86476b

View File

@@ -1,4 +1,4 @@
name: 'Update artifacts'
name: 'Build'
on:
push:
branches:
@@ -71,12 +71,13 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: ESlint
run: pnpm run lint
- name: Build
run: |
pnpm run build
- name: Push artifacts
if: ${{ github.event.pull_request.merged == true }}
run: |
git config --global user.email "noreply@github.com"
git config --global user.name "CI"
git diff --quiet || (git add -A && git commit -m "build: update bundled artifacts [skip ci]" && git push)