|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + pull_request: |
| 7 | +jobs: |
| 8 | + build_site: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v2 |
| 12 | + - id: nvm |
| 13 | + run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" |
| 14 | + - uses: actions/setup-node@v2-beta |
| 15 | + with: |
| 16 | + node-version: "${{ steps.nvm.outputs.NVMRC }}" |
| 17 | + - uses: actions/cache@v2 |
| 18 | + with: |
| 19 | + path: ~/.npm |
| 20 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 21 | + restore-keys: | |
| 22 | + ${{ runner.os }}-node- |
| 23 | + - run: npm install --no-optional --no-audit --no-fund --progress=false |
| 24 | + - run: npm run build |
| 25 | + - uses: actions/setup-python@v2 |
| 26 | + with: |
| 27 | + python-version: "3.9" |
| 28 | + - uses: Gr1n/setup-poetry@v4 |
| 29 | + with: |
| 30 | + poetry-version: '1.1.4' |
| 31 | + - uses: actions/cache@v2 |
| 32 | + with: |
| 33 | + path: ~/.cache/pip |
| 34 | + key: ${{ runner.os }}-python-${{ hashFiles('**/poetry.lock') }} |
| 35 | + restore-keys: | |
| 36 | + ${{ runner.os }}-python- |
| 37 | + - run: | |
| 38 | + poetry config virtualenvs.create false && |
| 39 | + poetry install |
| 40 | + - run: poetry run django-admin runserver --settings=tests.settings.production --pythonpath=. & |
| 41 | + # Python linting. |
| 42 | + - run: tox -e lint |
| 43 | + # Docs website build. |
| 44 | + - run: poetry run mkdocs build --strict |
| 45 | + # Demo website build. |
| 46 | + - run: wget --mirror --page-requisites --no-parent --no-verbose http://localhost:8000/django-pattern-library/demo/pattern-library/ |
| 47 | + - run: mv localhost:8000/django-pattern-library/demo site |
| 48 | + # Demo render_patterns. |
| 49 | + - run: poetry run django-admin render_patterns --settings=tests.settings.production --pythonpath=. --wrap-fragments --output=site/dpl-rendered-patterns |
| 50 | + # Package build, incl. publishing an experimental pre-release via GitHub Pages for builds on `master`. |
| 51 | + - run: cat pyproject.toml| awk '{sub(/^version = .+/,"version = \"0.0.0.dev\"")}1' > pyproject.toml.tmp && mv pyproject.toml.tmp pyproject.toml |
| 52 | + - run: poetry build |
| 53 | + - run: mv dist site |
| 54 | + - uses: actions/upload-artifact@v2 |
| 55 | + with: |
| 56 | + name: site |
| 57 | + path: site |
| 58 | + retention-days: 1 |
| 59 | + deploy_site: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + needs: build_site |
| 62 | + if: github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v2 |
| 65 | + - uses: actions/download-artifact@v2 |
| 66 | + - uses: JamesIves/[email protected] |
| 67 | + with: |
| 68 | + branch: gh-pages |
| 69 | + folder: site |
| 70 | + clean: true |
0 commit comments