Skip to content

fix: check layout export #15

fix: check layout export

fix: check layout export #15

Workflow file for this run

name: qgs-ai-summary
# Post a concise, human-readable summary of the real changes to QGIS .qgs
# project files on a PR. scripts/qgs-diff.py builds a churn-free diff of the
# changed files; the GitHub Copilot CLI turns it into per-file bullet points;
# the result is posted as a single self-updating PR comment. Nothing derived
# is committed.
on:
pull_request:
paths:
- '**/*.qgs'
permissions:
contents: read
pull-requests: write
copilot-requests: write
concurrency:
group: qgs-ai-summary-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
summarise:
runs-on: ubuntu-latest
env:
MODEL: gpt-5-mini
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Build churn-free diff
id: diff
run: |
WORK="$RUNNER_TEMP/qgs-ai"
mkdir -p "$WORK"
python3 scripts/qgs-diff.py diff --base "${{ github.base_ref }}" > "$WORK/diff.txt"
[ -s "$WORK/diff.txt" ] && echo "changed=1" >> "$GITHUB_OUTPUT" || echo "changed=0" >> "$GITHUB_OUTPUT"
- name: Set up Node for the Copilot CLI
if: steps.diff.outputs.changed == '1'
uses: actions/setup-node@v4
with:
node-version: 24
- name: Install Copilot CLI
if: steps.diff.outputs.changed == '1'
run: npm install -g @github/copilot
- name: Summarise with the Copilot CLI
id: ai
if: steps.diff.outputs.changed == '1'
env:
# Built-in workflow token — the Copilot CLI authenticates from this
# (via the copilot-requests permission), so no PAT/secret is needed.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
WORK="$RUNNER_TEMP/qgs-ai"
cd "$WORK"
copilot \
--model "$MODEL" \
--allow-all-tools \
--no-ask-user \
--max-ai-credits 50 \
-p 'Read the whole of the file diff.txt in the current directory with
your file-reading tool. It is small - do NOT grep/search it: its unified
-diff headers (---, +++, @@) contain regex metacharacters that make the
search tool error out.
It contains changes to QGIS .qgs project files for a pull request; QGIS
session churn has already been stripped, so ignore residual noise
(reordered attributes, internal ids, emptied values).
Write a concise, scannable GitHub-flavored-markdown summary of the
substantive changes only: layers added / removed / renamed / reordered,
symbology, labelling, scale ranges, print layouts, project CRS,
variables, map themes, expressions, data sources. Do not restate raw
XML, omit unchanged files, never invent changes.
Format it exactly like this:
- Start each changed file with a heading: "### `<path>`" (path in backticks).
- Directly under the heading, write a one-line _italic_ TL;DR (1-2
sentences) of what changed in that file.
- Then list the changes as bullets, grouped under short **bold**
sub-labels where it helps (e.g. **Layers**, **Symbology**,
**Labelling**, **Scale**, **Layout**, **Data sources**, **Project**).
Omit any group with no changes. Name the actual layers, properties
and values.
- Separate consecutive files with a horizontal rule (---).
Write ONLY this markdown (no preamble or conclusion) to a file named
summary.md in the current directory.' || true
cp "$WORK/summary.md" "$GITHUB_WORKSPACE/summary.md" 2>/dev/null || true
- name: Post sticky PR comment
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
PR: ${{ github.event.pull_request.number }}
CHANGED: ${{ steps.diff.outputs.changed }}
MODEL: ${{ env.MODEL }}
run: |
set -euo pipefail
MARKER='<!-- qgs-ai-summary -->'
{
echo "$MARKER"
echo "## 🗺️ QGIS project change summary"
echo
if [ "$CHANGED" = "1" ] && [ -s summary.md ]; then
cat summary.md
echo
echo "<sub>Generated by \`$MODEL\` via the GitHub Copilot CLI from a churn-free diff - verify against the file diff.</sub>"
else
echo "_No substantive QGIS project changes detected - only QGIS session churn._"
fi
} > comment.md
id=$(gh api "repos/$REPO/issues/$PR/comments" --paginate \
--jq ".[] | select(.body | contains(\"$MARKER\")) | .id" | head -n1)
if [ -n "$id" ]; then
gh api -X PATCH "repos/$REPO/issues/comments/$id" -F body=@comment.md >/dev/null
echo "updated comment $id"
else
gh api -X POST "repos/$REPO/issues/$PR/comments" -F body=@comment.md >/dev/null
echo "created comment"
fi