Skip to content

Build

Build #3711

Workflow file for this run

name: Build
on:
push:
pull_request:
schedule:
- cron: '20 20 * * *'
workflow_dispatch:
inputs:
tmate:
type: boolean
description: Run with tmate enabled
required: false
default: false
jobs:
build:
runs-on: ubuntu-latest
container: # https://stackoverflow.com/a/74341376
image: satantime/puppeteer-node:lts
env:
TZ: Asia/Shanghai
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Install Dependencies
run: |
apt update -y
apt upgrade -y
apt install -y jq
- name: Fix file ownerships
run: chown -R "$(whoami):$(whoami)" .
- run: npx pnpm i
- uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.tmate }}
- run: npx pnpm build
env:
MEILI_URL: ${{ secrets.MEILI_URL }}
MEILI_SEARCH_KEY: ${{ secrets.MEILI_SEARCH_KEY }}
- name: Download muffet
uses: nick-fields/retry@v3
with:
timeout_minutes: 1
max_attempts: 5
retry_wait_seconds: 30
command: |
wget -c "$(curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/raviqqe/muffet/releases/latest | jq -r '.assets[] | select(.name | test("linux_amd64")) | .browser_download_url')"
mkdir -p muffet
tar xf muffet_linux_amd64.tar.gz -C muffet
- name: Check links
run: |
npm exec -- iles preview --host 127.0.0.1 &
sleep 10
muffet/muffet http://127.0.0.1:4173 -i 'http://127.0.0.1' --max-response-body-size 16777216
- name: Get deploy commit message
id: deploy-commit-message
run: |
delimiter="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 20)"
echo "message<<$delimiter" >> "$GITHUB_OUTPUT"
git show -q --pretty="(${{ github.event_name }}) %B
https://github.com/${{ github.repository }}/commit/%H
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
" >> "$GITHUB_OUTPUT"
echo "$delimiter" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: dist
path: dist
- uses: peaceiris/actions-gh-pages@v4
if: github.repository_owner == 'ouuan' && github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
with:
publish_dir: dist
publish_branch: dist
external_repository: ouuan/ouuan.moe
personal_token: ${{ secrets.DEPLOY_TOKEN }}
full_commit_message: ${{ steps.deploy-commit-message.outputs.message }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
- name: Update post list in GitHub profile
if: github.repository_owner == 'ouuan' && github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: benc-uk/workflow-dispatch@v1
with:
workflow: blog-posts.yml
repo: ouuan/ouuan
token: ${{ secrets.PROFILE_POST_LIST_TOKEN }}
update-documents:
needs: build
if: github.repository_owner == 'ouuan' && github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install -r meili/requirements.txt
- run: python meili/update-documents.py
env:
MEILI_URL: ${{ secrets.MEILI_URL }}
MEILI_ADMIN_KEY: ${{ secrets.MEILI_ADMIN_KEY }}