docs/.github/workflows/ci.yml
2021-03-25 02:14:59 +01:00

100 lines
2.8 KiB
YAML

name: CI
on:
push:
pull_request:
schedule:
- cron: '0 2 * * *'
jobs:
Build:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install pipenv
run: pip install pipenv
- id: cache-pipenv
name: Download cache
uses: actions/cache@v2
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: Install dependencies
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: pipenv install --deploy --dev
- name: Build gettext strings
run: pipenv run sphinx-build -b gettext source build/locale
- name: Push and Pull strings from the Crowdin
uses: crowdin/github-action@1.1.0
if: github.ref == 'refs/heads/master'
with:
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
upload_sources: ${{ github.event_name == 'push' }}
download_translations: true
push_translations: false
download_language: en # Temporary limit only to English
- name: Fix permissions to the locale dir
if: github.ref == 'refs/heads/master'
run: sudo chown -R $USER:$USER locale
- name: Build docs
run: pipenv run python build-multilang.py
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: build
path: build
retention-days: 7
- id: detect-diffs
name: Detect diffs
if: github.event_name == 'schedule'
run: |
git fetch origin
gh_pages_exists=$(git ls-remote --heads origin gh-pages)
if [[ -z ${gh_pages_exists} ]]; then
echo "::warning::gh_pages branch doesn't exists"
echo "::set-output name=should-continue::false"
exit
fi
tmp_dir=$(mktemp -du)
git worktree add "$tmp_dir" origin/gh-pages
diff_detected=false
for l in locale/*; do
l=$(basename $l)
if ! diff -qbB -- "build/$l" "$tmp_dir/$l" > /dev/null; then
diff_detected=true
break
fi
done
echo "::set-output name=should-continue::$diff_detected"
- name: Deploy to the GitHub Pages
uses: JamesIves/github-pages-deploy-action@4.1.0
if: |
(github.event_name == 'push' && 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