Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub action for pretext deploy #644

Open
StevenClontz opened this issue Nov 13, 2023 · 5 comments
Open

GitHub action for pretext deploy #644

StevenClontz opened this issue Nov 13, 2023 · 5 comments

Comments

@StevenClontz
Copy link
Member

In an ideal world, I should be able to push my updated PreTeXt project to main, and then GitHub actions builds/generates everything and deploys it. This is particularly useful for projects such as https://github.com/TeamBasedInquiryLearning/linear-algebra that involve multiple contributors: I'd especially love to see a preview of the built project on every pull request, or a failed CI notification when the project doesn't build with the proposed contribution. Then when I thumbs-up the contribution and merge it into main, I get a fresh build and deployment automatically.

@cmhughes
Copy link

My attempt (which fails) at this is

name: cmh-deploy-gh-pages

on:
  push:

jobs:
  cmh-preTeXt-build:
    runs-on: ubuntu-latest
    steps:
      - name: install python
        uses: actions/setup-python@v4
        with:
          python-version: "3.11"
      - name: Install pretext
        run: |
          python -m ensurepip
          python -m pip install --upgrade pip
          python -m pip install --upgrade pretext
      - name: load the "base actions/checkout" so as to access cmh-preTeXt-explore
        uses: actions/checkout@v4
      - name: cmh-build-html
        run: pretext build web
      - name: cmh-deploy-html
        run: pretext deploy

Here's a link to my repo: https://github.com/cmhughes/preTeXt-cmh-explore/tree/main and the failing action log: https://github.com/cmhughes/preTeXt-cmh-explore/actions/runs/7583169500/job/20654242271

I'd love to know what I'm doing wrong, and if anyone knows how to fix this.

@StevenClontz
Copy link
Member Author

Thanks for the attempt! I haven't looked closely at this PR, but my hot take is that the issue here is that I wouldn't expect pretext deploy to work within an action. What the pretext deploy CLI command does is a bunch of git commands which the GitHub Action probably (shouldn't?) have permissions to perform in order to get files pushed to a gh-pages branch. Instead, our ideal GitHub action should perform some combination of https://github.com/actions/upload-pages-artifact and https://github.com/actions/deploy-pages to deploy an update that doesn't touch the repository itself (importantly, not inflating the size of a repo with the history of its deployments).

@cmhughes
Copy link

cmhughes commented Jan 20, 2024

Thanks for the response 😊

Just to be clear, I'm not submitting a pull request (PR).

I'm a little confused about your point as looking at the following, which is run from within the devcontainer, this looks very much like a github action

https://github.com/cmhughes/preTeXt-cmh-explore/actions/runs/7581933289

But I've probably misunderstood things!

@cmhughes
Copy link

For anyone interested, I've now got a working demonstration of this at https://github.com/cmhughes/preTeXt-cmh-explore using the following GitHubActions

name: cmh-deploy-gh-pages

on:
  push:

permissions:
  contents: write

jobs:
  cmh-preTeXt-build:
    runs-on: ubuntu-latest
    steps:
      - name: install python
        uses: actions/setup-python@v4
        with:
          python-version: "3.11"
      - name: Install pretext
        run: |
          python -m ensurepip
          python -m pip install --upgrade pip
          python -m pip install --upgrade pretext
      - name: load the "base actions/checkout" so as to access cmh-preTeXt-explore
        uses: actions/checkout@v4
      - name: cmh-build-html
        run: pretext build web
      - name: cmh-deploy-html-NEW
        # https://github.com/marketplace/actions/deploy-to-github-pages
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          folder: output/web

references/links

my next step

I'm hoping to append the above to produce a (latex-generated) pdf, and deploy it somewhere appropriate to the repo above.

@StevenClontz
Copy link
Member Author

Thanks - taking a closer look now.

I think you figured out what I poorly alluded to the other day: rather than using pretext deploy in an Action (which does a bunch of Git branch management and assumes the machine has Git permissions), using something like the JamesIves/github-pages-deploy-action@v4 custom action intended to deploy arbitrary files to GitHub Pages feels like the way to go.

My next hint would be that the basic ubuntu-latest machine won't have all the TeX installations needed to produce a PDF. But maybe the action can be wired up to use one of these docker images? https://github.com/cmhughes/preTeXt-cmh-explore/blob/3ed7015fd6eedf2c123e7d20602b64e8315ab49b/.devcontainer.json#L17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants