|
| 1 | +name: Build and deploy docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +env: |
| 10 | + NODE_VERSION: 20 |
| 11 | + PYTHON_VERSION: 3.12 |
| 12 | + |
| 13 | +jobs: |
| 14 | + build_and_deploy_docs: |
| 15 | + environment: |
| 16 | + name: github-pages |
| 17 | + permissions: |
| 18 | + contents: write |
| 19 | + pages: write |
| 20 | + id-token: write |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} |
| 28 | + |
| 29 | + - name: Set up Node |
| 30 | + uses: actions/setup-node@v4 |
| 31 | + with: |
| 32 | + node-version: ${{ env.NODE_VERSION }} |
| 33 | + cache: npm |
| 34 | + cache-dependency-path: website/package-lock.json |
| 35 | + |
| 36 | + - name: Install Node dependencies |
| 37 | + run: | |
| 38 | + npm install |
| 39 | + npm update @apify/docs-theme |
| 40 | + working-directory: ./website |
| 41 | + |
| 42 | + # We do this as early as possible to prevent conflicts if someone else would push something in the meantime |
| 43 | + - name: Commit the updated package.json and lockfile |
| 44 | + run: | |
| 45 | + git config user.name 'GitHub Actions' |
| 46 | + git config user.email 'github-actions[bot]@users.noreply.github.com' |
| 47 | + git add website/package.json |
| 48 | + git add website/package-lock.json |
| 49 | + git diff-index --quiet HEAD || git commit -m 'chore: Automatic docs theme update [skip ci]' || true |
| 50 | + git push |
| 51 | +
|
| 52 | + - name: Set up Python |
| 53 | + uses: actions/setup-python@v5 |
| 54 | + with: |
| 55 | + python-version: ${{ env.PYTHON_VERSION }} |
| 56 | + |
| 57 | + - name: Install Python dependencies |
| 58 | + run: | |
| 59 | + pipx install --python ${{ env.PYTHON_VERSION }} poetry |
| 60 | + make install-dev |
| 61 | +
|
| 62 | + - name: Build generated API reference |
| 63 | + run: make build-api-reference |
| 64 | + |
| 65 | + - name: Build Docusaurus docs |
| 66 | + run: make build-docs |
| 67 | + |
| 68 | + - name: Set up GitHub Pages |
| 69 | + uses: actions/configure-pages@v5 |
| 70 | + |
| 71 | + - name: Upload GitHub Pages artifact |
| 72 | + uses: actions/upload-pages-artifact@v3 |
| 73 | + with: |
| 74 | + path: ./website/build |
| 75 | + |
| 76 | + - name: Deploy artifact to GitHub Pages |
| 77 | + uses: actions/deploy-pages@v4 |
| 78 | + |
| 79 | + - name: Invalidate CloudFront cache |
| 80 | + run: gh workflow run invalidate.yaml --repo apify/apify-docs-private |
| 81 | + env: |
| 82 | + GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} |
0 commit comments