From 8edb86476b737f443b60ffc2ba16717f734a5ac5 Mon Sep 17 00:00:00 2001 From: Sped0n Date: Sat, 4 Nov 2023 21:02:43 +0800 Subject: [PATCH] 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 --- .github/workflows/{artifacts.yml => build.yml} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename .github/workflows/{artifacts.yml => build.yml} (94%) diff --git a/.github/workflows/artifacts.yml b/.github/workflows/build.yml similarity index 94% rename from .github/workflows/artifacts.yml rename to .github/workflows/build.yml index e0c4cc7..4a806d1 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/build.yml @@ -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)