diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 371d26c..c28ef44 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,34 +12,11 @@ permissions: contents: write jobs: - filter: - runs-on: ubuntu-latest - name: Filter - outputs: - any_changed: ${{ steps.changed-files-specific.outputs.any_changed }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Get changed files in scope - id: changed-files-specific - uses: tj-actions/changed-files@v47 - with: - files: | - package.json - pnpm-lock.yaml - tsconfig.json - vite.config.ts - assets/** - build: timeout-minutes: 30 runs-on: ubuntu-latest name: Build (Hugo ${{ matrix.hugo-label }}) - needs: [filter] - if: | - github.event.repository.fork == false + if: github.event.repository.fork == false strategy: matrix: hugo-version: ['latest', '0.114.0'] @@ -49,59 +26,52 @@ jobs: - hugo-version: '0.114.0' hugo-label: 'v0.114.0' steps: - - name: Set current date as env variable - run: | - echo "builddate=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT - id: version - - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: token: ${{ secrets.PAT }} - - name: Setup Hugo - uses: peaceiris/actions-hugo@v2.6.0 + - name: Setup Mise + uses: jdx/mise-action@v3 with: - hugo-version: ${{ matrix.hugo-version }} - extended: true + install_args: node@latest pnpm@10 hugo-extended@${{ matrix.hugo-version }} + tool_versions: | + node latest + pnpm 10 + hugo-extended ${{ matrix.hugo-version }} + cache: true - - name: Setup pnpm - uses: pnpm/action-setup@v3 - with: - version: 10 - - - name: Get pnpm store directory + - name: Get pnpm store path id: pnpm-cache - run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + run: 'echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT' - name: Setup pnpm cache - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('./pnpm-lock.yaml') }} + key: pnpm-store-${{ hashFiles('./pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-pnpm-store- + pnpm-store- - - name: Setup hugo cache - uses: actions/cache@v4 + - name: Setup Hugo cache + uses: actions/cache@v5 with: - path: ./exampleSite/resources - key: ${{ runner.os }}-hugo-${{ matrix.hugo-version }}-${{ hashFiles('./exampleSite') }} + path: exampleSite/resources/_gen + key: hugo-${{ matrix.hugo-version }}-${{ hashFiles('./exampleSite/**/*.jpg') }} restore-keys: | - ${{ runner.os }}-hugo-${{ matrix.hugo-version }}- + hugo-${{ matrix.hugo-version }}- - - name: Install dependencies - run: pnpm install + - name: Install project dependencies + run: 'pnpm install' - name: Build - run: | - pnpm run build + run: 'pnpm run build' - - name: Push artifacts + - name: Commit if: > matrix.hugo-version == 'latest' && - (github.event_name == 'push' || github.event.pull_request.merged == true) && - needs.filter.outputs.any_changed == 'true' - uses: stefanzweifel/git-auto-commit-action@v5 + (github.event_name == 'push' || github.event.pull_request.merged == true) + uses: stefanzweifel/git-auto-commit-action@v7 with: + file_pattern: 'bundled/**/*.js bundled/**/*.css' commit_message: 'ci: update bundled artifacts [skip ci]' diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml deleted file mode 100644 index 75f7d85..0000000 --- a/.github/workflows/eslint.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: 'ESLint && Prettier' -on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_dispatch: - -permissions: - contents: write - -jobs: - lint: - runs-on: ubuntu-latest - name: Lint - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - token: ${{ secrets.PAT || github.token }} - - - name: Setup pnpm - uses: pnpm/action-setup@v3 - with: - version: 10 - - - name: Get pnpm store directory - id: pnpm-cache - run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - name: Setup pnpm cache - uses: actions/cache@v4 - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('./pnpm-lock.yaml') }} - restore-keys: ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Lint Check - continue-on-error: true - id: check - run: pnpm run lint:check - - - name: Format manually - id: format - if: ${{ steps.check.outcome == 'failure' }} - run: pnpm run lint - - - name: Commit - if: ${{ steps.format.outcome == 'success' }} - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: 'ci: format code [skip ci]' diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..b30cd6c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,58 @@ +name: 'Lint' +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +permissions: + contents: write + +jobs: + lint: + runs-on: ubuntu-latest + name: Lint + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + # github.token as a fallback, since other user might trigger this + # workflow in their pull request + token: ${{ secrets.PAT || github.token }} + + - name: Setup Mise + uses: jdx/mise-action@v3 + with: + install_args: node@latest pnpm@10 + tool_versions: | + node latest + pnpm 10 + cache: true + + - name: Get pnpm store path + id: pnpm-cache + run: 'echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT' + + - name: Setup pnpm cache + uses: actions/cache@v5 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: pnpm-store-${{ hashFiles('./pnpm-lock.yaml') }} + restore-keys: | + pnpm-store- + + - name: Install project dependencies + run: 'pnpm install' + + - name: Lint + id: lint + run: 'pnpm run lint:check || pnpm run lint' + + - name: Commit + if: ${{ steps.format.lint == 'success' }} + uses: stefanzweifel/git-auto-commit-action@v7 + with: + commit_message: 'ci: lint [skip ci]'