Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# https://github.github.io/actions-cheat-sheet/actions-cheat-sheet.html
# https://github.com/actions/checkout

on:
push:
branches:
- '[0-9]+\.[0-9]+'
pull_request:
workflow_dispatch:

name: html-preview

jobs:
int-test:
name: Generate HTML preview
runs-on: ubuntu-latest

permissions:
pull-requests:
write

steps:
# https://stackoverflow.com/a/74268200
- uses: actions/checkout@v6
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Get diff range to compare
id: diff_range
run: |
if ${{ github.event_name == 'pull_request' }}; then
echo "diff_range=HEAD^1..HEAD" >> $GITHUB_OUTPUT
else
echo "diff_range=${{ github.event.before }}..${{ github.event.after }}" >> $GITHUB_OUTPUT
fi

- name: Check out CLiC
# NB: Checks out into GITHUB_WORKSPACE, e.g. /home/runner/work/clic/clic
uses: actions/checkout@v6
with:
repository: mahlberg-lab/clictagger
path: clictagger
- uses: actions/setup-python@v6
with:
python-version: '3.13'
cache: 'pip'
cache-dependency-path: |
clictagger/setup.py
- name: Install clictagger from checked out source
run: pip install ./clictagger
- name: Generate HTML for all changes
run: |
# For each changed file...
git diff --name-only "${{ steps.diff_range.outputs.diff_range }}" -- '*/*.txt' | while read -r f ; do
if [ -e "$(dirname "${f}")/$(basename "${f}" .txt).regions.csv" ]; then
# Can't output a diff if using regions.csv
echo "${f}"
else
# Output diff, showing only new lines (NB: A new file is all new lines)
mkdir -p "$(dirname "new/${f}")"
git diff -U10 --no-indent-heuristic --color=never --output-indicator-new=" " \
"${{ steps.diff_range.outputs.diff_range }}" -- "${f}" \
| awk '/^ / { print substr($_, 2) } /^@/ { print "\n . . . . unchanged text . . . .\n" }' \
| tail -n+4 \
> "new/${f}"
echo "new/${f}"
fi
done | xargs clictagger --html index.html
# https://github.com/pavi2410/html-preview-action
- name: HTML Preview
id: html_preview
uses: pavi2410/html-preview-action@b58683c238478d5f8b5dacf4fe5e3f403afb449a
with:
html_file: index.html
site_root: .
upload: auto
job_summary: true
- name: Comment preview artifact on PR
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@a111a2c3bacd7be7898ee22d0d71d9aec2bb972c
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
[Preview of these changes with CLiC tags](${{ steps.html_preview.outputs.artifact_url }})
4 changes: 2 additions & 2 deletions ChiLit/alice.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Alice was beginning to get very tired of sitting by her sister on the
bank, and of having nothing to do: once or twice she had peeped into the
book her sister was reading, but it had no pictures or conversations in
it, ‘and what is the use of a book,’ thought Alice ‘without pictures or
conversations?’
conversations?’. ‘Hello there,’ someone else said inconsequently ‘I've stubbed my toe’.

So she was considering in her own mind (as well as she could, for the
hot day made her feel very sleepy and stupid), whether the pleasure
Expand Down Expand Up @@ -249,7 +249,7 @@ hopeless than ever: she sat down and began to cry again.
you,’ (she might well say this), ‘to go on crying in this way! Stop this
moment, I tell you!’ But she went on all the same, shedding gallons of
tears, until there was a large pool all round her, about four inches
deep and reaching half down the hall.
deep and reaching half down the hall. ‘Hello there,’ someone else said inconsequently ‘I've stubbed my toe’.

After a time she heard a little pattering of feet in the distance, and
she hastily dried her eyes to see what was coming. It was the White
Expand Down
Loading