build #388
This file contains 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 | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
workflow_run: | |
workflows: ['Sync Global Documentation'] | |
types: | |
- completed | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install markdown pyyaml beautifulsoup4 | |
- name: Build all documentation | |
id: build | |
run: | | |
export TUNA_TEMP_DIR=$(mktemp -d) | |
git worktree add --no-checkout --detach "$TUNA_TEMP_DIR" origin/transpiled | |
cat enabled.txt | xargs python global/compile.py -v --lang zh -C dom -C tuna | |
git -C "$TUNA_TEMP_DIR" add --all --verbose | |
if git -C "$TUNA_TEMP_DIR" diff --exit-code --quiet --cached; then | |
echo "No changes to commit." | |
echo "changed=false" >> "$GITHUB_OUTPUT" | |
exit 0 | |
fi | |
git -C "$TUNA_TEMP_DIR" \ | |
-c user.name="GitHub Actions" \ | |
-c user.email="github-actions[bot]@users.noreply.github.com" \ | |
commit -m "Auto build for $GITHUB_REPOSITORY@${GITHUB_SHA::7}" | |
git -C "$TUNA_TEMP_DIR" push --force origin HEAD:transpiled | |
echo "changed=true" >> "$GITHUB_OUTPUT" | |
echo "new_commit=$(git -C "$TUNA_TEMP_DIR" rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
- name: Trigger mirror-web update | |
uses: actions/github-script@v6 | |
if: steps.build.outputs.changed == 'true' | |
env: | |
NEW_COMMIT: ${{ steps.build.outputs.new_commit }} | |
with: | |
github-token: ${{ secrets.MIRROR_WEB_TRIGGER_PAT }} | |
script: | | |
github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: 'mirror-web', | |
workflow_id: 'sync-helpz.yml', | |
ref: 'master', | |
inputs: { | |
'new_commit': process.env.NEW_COMMIT, | |
}, | |
}); |