Build #120
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 | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| schedule: | |
| - cron: '0 0 * * *' # Daily at midnight UTC | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 'latest' | |
| - name: Install dependencies | |
| run: npm install --ignore-scripts | |
| - name: Validate JSON files | |
| run: npm run validate | |
| - name: Lint JavaScript files | |
| run: npm run lint | |
| - name: Build indexes | |
| run: npm run build | |
| - name: Upload dist artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| if-no-files-found: 'error' | |
| name: dist | |
| path: dist/ | |
| publish: | |
| needs: build | |
| if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'schedule' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Download dist artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Publish to dist branch | |
| env: | |
| GH_BOT_NAME: ${{ vars.GH_BOT_NAME }} | |
| GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }} | |
| GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }} | |
| run: | | |
| git config --global user.name "${GH_BOT_NAME}" | |
| git config --global user.email "${GH_BOT_EMAIL}" | |
| git clone --single-branch --branch dist \ | |
| "https://x-access-token:${GH_BOT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" dist-repo \ | |
| || git clone "https://x-access-token:${GH_BOT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" dist-repo | |
| cd dist-repo | |
| git checkout dist 2>/dev/null || git checkout --orphan dist | |
| git rm -rf . 2>/dev/null || true | |
| cp -r ../dist/* . | |
| git add . | |
| git diff --staged --quiet || git commit -m "build: update dist from ${GITHUB_SHA}" | |
| git push "https://x-access-token:${GH_BOT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" dist |