Scaffold PDF preview and Copilot instructions in generated book projects - #72
Merged
Merged
Conversation
Co-authored-by: demccormack <52194107+demccormack@users.noreply.github.com>
Co-authored-by: demccormack <52194107+demccormack@users.noreply.github.com>
Co-authored-by: demccormack <52194107+demccormack@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add automation tools to generated projects
Scaffold PDF preview and Copilot instructions in generated book projects
Sep 20, 2026
demccormack
marked this pull request as ready for review
September 20, 2026 11:47
demccormack
requested changes
Sep 20, 2026
demccormack
left a comment
Owner
There was a problem hiding this comment.
@copilot I forgot we already have build.yml doing some of this. So remove the new workflow and adapt build.yml to my requirements. Here is an example of how it should look if the new book was called "The Verse Awakens":
name: Build LaTeX PDF
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Setup LaTeX
uses: xu-cheng/latex-action@v4
with:
root_file: main.tex
- name: Rename PDF with commit SHA
run: mv main.pdf the-verse-awakens-${{ github.sha }}.pdf
- name: Upload PDF preview artifact
id: upload-pdf
uses: actions/upload-artifact@v7
with:
name: the-verse-awakens-${{ github.sha }}.pdf
path: the-verse-awakens-${{ github.sha }}.pdf
archive: false
- name: Add PDF preview to PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v9
env:
ARTIFACT_URL: ${{ steps.upload-pdf.outputs.artifact-url }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
MERGE_SHA: ${{ github.sha }}
with:
script: |
const marker = '<!-- pdf-preview -->';
const headSha = process.env.PR_HEAD_SHA;
const mergeSha = process.env.MERGE_SHA;
const body = `${marker}
### 📖 PDF Preview
**[Open PDF preview ↗](${process.env.ARTIFACT_URL})**
Includes PR commit ${headSha.substring(0, 7)}
Built from merge commit ${mergeSha.substring(0, 7)}`;
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existingComments = comments.filter(
comment =>
comment.user.type === 'Bot' &&
comment.body.includes(marker)
);
for (const comment of existingComments) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
});
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
- name: Create Release (on tag)
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v3
with:
files: the-verse-awakens-${{ github.sha }}.pdf
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Co-authored-by: demccormack <52194107+demccormack@users.noreply.github.com>
Co-authored-by: demccormack <52194107+demccormack@users.noreply.github.com>
Contributor
Author
Addressed in 2a8e8ee. The generated |
📖 PDF Preview |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated book repositories were missing two pieces of repo automation expected by the issue: a PR PDF preview workflow and a repository-specific Copilot instructions file. This change extends
write newso newly scaffolded projects include both, with title- and project-specific substitutions applied at generation time.Scaffolded GitHub automation
/.github/workflows/pdf_preview.ymlfor book repos.main.tex, upload a SHA-suffixed PDF artifact, and post/update a PR comment with the preview link.Generated Copilot instructions
/.github/copilot-instructions.mdto generated projects.Consistent template substitution
main.tex,book.toml, and the new Copilot instructions file.Scaffold contract updates
Example of the new generated workflow naming: