|
| 1 | +# <!-- Managed automatically by PreTeXt authoring tools --> |
| 2 | +# (delete the above line to manage this file manually) |
| 3 | + |
| 4 | +name: PreTeXt-CLI Actions |
| 5 | +on: |
| 6 | + # Runs on pull requests |
| 7 | + pull_request: |
| 8 | + branches: ["*"] |
| 9 | + # Runs on pushes to main |
| 10 | + push: |
| 11 | + branches: ["main"] |
| 12 | + # Runs on demand |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + container: oscarlevin/pretext:full |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout source |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: install deps |
| 25 | + run: pip install -r requirements.txt |
| 26 | + |
| 27 | + - name: build deploy targets |
| 28 | + run: pretext build --deploys |
| 29 | + - name: stage deployment |
| 30 | + run: pretext deploy --stage-only |
| 31 | + |
| 32 | + - name: Bundle output/stage as artifact |
| 33 | + uses: actions/upload-artifact@v4 |
| 34 | + with: |
| 35 | + name: deploy |
| 36 | + path: output/stage |
| 37 | + |
| 38 | + deploy-cloudflare: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + needs: build |
| 41 | + if: vars.CLOUDFLARE_PROJECT_NAME != '' |
| 42 | + permissions: |
| 43 | + contents: read |
| 44 | + deployments: write |
| 45 | + |
| 46 | + steps: |
| 47 | + - name: Download artifact |
| 48 | + uses: actions/download-artifact@v4 |
| 49 | + with: |
| 50 | + name: deploy |
| 51 | + path: deploy |
| 52 | + - name: Create 404.html |
| 53 | + run: echo "404 page not found" >> deploy/404.html |
| 54 | + - name: Publish to Cloudflare |
| 55 | + uses: cloudflare/pages-action@v1 |
| 56 | + with: |
| 57 | + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 58 | + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
| 59 | + projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }} |
| 60 | + gitHubToken: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + branch: ${{ github.head_ref || github.ref_name }} |
| 62 | + directory: deploy |
| 63 | + |
| 64 | + deploy-ghpages: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + needs: build |
| 67 | + if: vars.PTX_ENABLE_DEPLOY_GHPAGES == 'yes' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) |
| 68 | + permissions: |
| 69 | + contents: read |
| 70 | + pages: write |
| 71 | + id-token: write |
| 72 | + concurrency: |
| 73 | + group: "page" |
| 74 | + cancel-in-progress: false |
| 75 | + environment: |
| 76 | + name: github-pages |
| 77 | + url: ${{ steps.deployment.outputs.page_url }} |
| 78 | + steps: |
| 79 | + - name: Download website artifact |
| 80 | + uses: actions/download-artifact@v4 |
| 81 | + with: |
| 82 | + name: deploy |
| 83 | + path: deploy |
| 84 | + - name: Setup GitHub Pages |
| 85 | + id: check |
| 86 | + uses: actions/configure-pages@v4 |
| 87 | + - name: Upload artifact |
| 88 | + uses: actions/upload-pages-artifact@v3 |
| 89 | + with: |
| 90 | + path: deploy |
| 91 | + - name: Deploy to Github Pages |
| 92 | + id: deployment |
| 93 | + uses: actions/deploy-pages@v4 |
0 commit comments