build-favorite #59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Hugo and Deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| # schedule: | |
| # - cron: '0 0 1 * *' | |
| workflow_dispatch: | |
| inputs: | |
| build_content: | |
| description: "选择构建范围:" | |
| required: true | |
| default: 'build-favorite' | |
| type: choice | |
| options: | |
| - 'build-favorite' | |
| repository_dispatch: | |
| types: [build-favorite] | |
| jobs: | |
| build-deploy: | |
| runs-on: ubuntu-latest | |
| env: | |
| HUGO_CACHEDIR: /tmp/.hugo_cache | |
| HUGOMODS_CACHEDIR: /tmp/.hugo_mods_cache | |
| PNPM_CACHEDIR: /tmp/.pnpm-store | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| fetch-depth: 0 | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@v3 | |
| with: | |
| hugo-version: 'latest' | |
| extended: true | |
| - name: Cache Hugo Resources | |
| uses: actions/cache@v4 | |
| id: cache-hugo | |
| with: | |
| path: | | |
| resources/_gen | |
| ${{ env.HUGO_CACHEDIR }} | |
| key: ${{ runner.os }}-hugo-${{ hashFiles('content/**', 'assets/**', 'layouts/**', 'config.toml', 'pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-hugo- | |
| - name: Cache Hugo Modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.HUGOMODS_CACHEDIR }} | |
| key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-hugomod- | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| cache: 'pnpm' | |
| - name: Fetch Directus links | |
| run: | | |
| pnpm install | |
| pnpm run directus | |
| env: | |
| DIRECTUS_API_URL: ${{ secrets.DIRECTUS_API_URL }} | |
| DIRECTUS_FILES_URL: ${{ secrets.DIRECTUS_FILES_URL }} | |
| DIRECTUS_ACCESS_TOKEN: ${{ secrets.DIRECTUS_ACCESS_TOKEN }} | |
| - name: Build Hugo | |
| run: | | |
| hugo --minify | |
| - name: Deploy to Aliyun OSS | |
| uses: docker://fangbinwei/aliyun-oss-website-action:v1 | |
| env: | |
| ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }} | |
| ACCESS_KEY_SECRET: ${{ secrets.ACCESS_KEY_SECRET }} | |
| BUCKET: s-eallion-com | |
| ENDPOINT: oss-cn-shanghai.aliyuncs.com | |
| FOLDER: public | |
| SKIP_SETTING: true | |
| INCREMENTAL: true |