Hi everybody,
I have a PreTeXt project in a subdirectory of a github repository, and I'm having trouble deploying to github pages.
The `pretext deploy` script needs to be run in the subdirectory (called `pretext`) in order to find the `project.ptx` file. But when I do this, it initializes a *new* git repository inside the pretext directory, then enters an interactive mode prompting the user to create a new remote repository on GitHub and paste the url. I tried pasting in the existing remote, but it also asked for an authentication token, and even then it didn't work. Plus, I want this to run remotely in a GitHub workflow.
To trick the `pretext deploy` command, I symlinked the top-level .git directory into the pretext directory, and deleted it afterwards. So instead of
pretext deploy --no-push
git push origin gh-pages --force
the steps are
cd pretext
ln -s ../.git .
pretext deploy --no-push
rm -rf .git
cd ..
git push origin gh-pages --force
This seems to work!
I worked these changes into the workflow file too.
* Any step where the "run" field is a pretext command has to have the "working-directory: ./pretext" key-value pair added.
* I added these steps before and after the deploy command:
- name: symlink parent .git to pretext
run: ln -s ../.git .git
working-directory: ./pretext
- name: deploy targets
run: pretext deploy --no-push
working-directory: ./pretext
- name: remove pretext .git symlink
run: rm -f .git
working-directory: ./pretext
You may guess that in the course of drafting this message, I have solved my problem. So my question is basically "Did I do that right?"
But if I could add a tangential request for enhancement: I think the main pretext command should have an option to specify a project directory other than the directory the command is executed from. And/or: the pretext deploy command should use another way of checking if it's "in" a git repository than looking for a .git subdirectory in the current directory.
Best,
Matthew
--
Matthew Leingang (he/his)
Clinical Professor of Mathematics
Courant Institute School of Mathematics, Computing, and Data Science
New York University