name: CI on: push: pull_request: schedule: # Nightly build to publish fresh translations from Crowdin - cron: '0 2 * * *' workflow_dispatch: permissions: contents: write concurrency: group: ${{ github.workflow }}-${{ github.ref }} jobs: build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: 22 cache: npm - name: Install dependencies run: npm ci - name: Generate source UI strings run: npm run write-translations -- --locale ru --override - name: Push and pull strings from the Crowdin uses: crowdin/github-action@v2 if: github.ref == 'refs/heads/master' with: upload_sources: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} upload_translations: false download_translations: true push_translations: false env: CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} - name: Fix permissions to the i18n dir if: github.ref == 'refs/heads/master' run: sudo chown -R "$USER:$USER" i18n - name: Detect locales to publish if: github.ref == 'refs/heads/master' run: echo "DOCS_LOCALES=$(node scripts/crowdin-locales.mjs)" >> "$GITHUB_ENV" env: CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} - name: Typecheck run: npm run typecheck - name: Build docs run: npm run build - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: build path: build include-hidden-files: true retention-days: 7 - id: detect-diffs name: Detect diffs if: github.event_name == 'schedule' run: | git fetch origin if [[ -z "$(git ls-remote --heads origin gh-pages)" ]]; then echo "::warning::gh-pages branch doesn't exist" echo "should-continue=false" >> "$GITHUB_OUTPUT" exit fi tmp_dir=$(mktemp -du) git worktree add "$tmp_dir" origin/gh-pages if diff -qrbB --exclude=.git build "$tmp_dir" > /dev/null; then echo "should-continue=false" >> "$GITHUB_OUTPUT" else echo "should-continue=true" >> "$GITHUB_OUTPUT" fi - name: Deploy to the GitHub Pages uses: JamesIves/github-pages-deploy-action@v4 if: | (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master') || (github.event_name == 'schedule' && steps.detect-diffs.outputs.should-continue == 'true') with: branch: gh-pages folder: build single-commit: true