|
1 | | -name: DataJoint Book GitHub Pages Deploy |
| 1 | +name: Build and Deploy DataJoint Book |
| 2 | + |
| 3 | +# Run on pushes to the main branch and on pull requests |
2 | 4 | on: |
3 | 5 | push: |
4 | 6 | # Runs on pushes targeting the default branch |
5 | 7 | branches: [main] |
6 | | -env: |
7 | | - # `BASE_URL` determines the website is served from, including CSS & JS assets |
8 | | - # You may need to change this to `BASE_URL: ''` |
9 | | - BASE_URL: /${{ github.event.repository.name }} |
| 8 | + pull_request: |
| 9 | + branches: [main] |
10 | 10 |
|
11 | 11 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
12 | 12 | permissions: |
13 | 13 | contents: read |
14 | 14 | pages: write |
15 | 15 | id-token: write |
| 16 | + |
16 | 17 | # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
17 | | -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
18 | 18 | concurrency: |
19 | | - group: 'pages' |
| 19 | + group: ${{ github.workflow }}-${{ github.ref }} |
20 | 20 | cancel-in-progress: false |
| 21 | + |
21 | 22 | jobs: |
22 | | - deploy: |
23 | | - environment: |
24 | | - name: github-pages |
25 | | - url: ${{ steps.deployment.outputs.page_url }} |
| 23 | + build: |
26 | 24 | runs-on: ubuntu-latest |
27 | 25 | steps: |
28 | | - - uses: actions/checkout@v4 |
29 | | - - name: Setup Pages |
30 | | - uses: actions/configure-pages@v3 |
31 | | - - uses: actions/setup-node@v4 |
| 26 | + - name: Checkout your repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Setup Node.js and cache dependencies |
| 30 | + uses: actions/setup-node@v4 |
32 | 31 | with: |
33 | | - node-version: 18.x |
| 32 | + node-version: '20' # Using a more current LTS version |
| 33 | + cache: 'npm' # ⚡️ Cache npm packages for faster subsequent runs |
| 34 | + |
34 | 35 | - name: Install MyST Markdown |
35 | 36 | run: npm install -g mystmd |
36 | | - - name: Build HTML Assets |
37 | | - run: | |
38 | | - cd book |
39 | | - myst build --html |
40 | | - - name: Upload artifact |
41 | | - uses: actions/upload-pages-artifact@v4 |
| 37 | + |
| 38 | + - name: Build HTML assets |
| 39 | + run: myst build book/myst.yml --html # It's good practice to specify the config file |
| 40 | + |
| 41 | + - name: Upload artifact for deployment |
| 42 | + uses: actions/upload-pages-artifact@v3 |
42 | 43 | with: |
43 | 44 | path: './book/_build/html' |
| 45 | + |
| 46 | + deploy: |
| 47 | + # Requires the build job to succeed |
| 48 | + needs: build |
| 49 | + |
| 50 | + # Deploy only when pushing to the main branch, not on pull requests |
| 51 | + if: github.ref == 'refs/heads/main' |
| 52 | + |
| 53 | + environment: |
| 54 | + name: github-pages |
| 55 | + url: ${{ steps.deployment.outputs.page_url }} |
| 56 | + |
| 57 | + runs-on: ubuntu-latest |
| 58 | + steps: |
44 | 59 | - name: Deploy to GitHub Pages |
45 | 60 | id: deployment |
46 | | - uses: actions/deploy-pages@v2 |
| 61 | + uses: actions/deploy-pages@v4 |
0 commit comments