Skip to content
Merged
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
54 changes: 54 additions & 0 deletions .github/workflows/jules-remove-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright NGGT.LightKeeper and Di120078. All Rights Reserved.

name: Jules - Remove PR

on:
pull_request:
types:
- opened

permissions:
pull-requests: write

jobs:
close-jules-pr:
if: |
startsWith(github.event.pull_request.head.ref, 'jules-docs-dev-') ||
startsWith(github.event.pull_request.head.ref, 'jules-patchnotes-dev-')
runs-on: ubuntu-latest
timeout-minutes: 2

steps:
- name: Close Jules automation pull request
uses: actions/github-script@v9
with:
script: |
const pr = context.payload.pull_request;
const owner = context.repo.owner;
const repo = context.repo.repo;
const number = pr.number;

if (pr.state !== "open") {
core.info(`PR #${number} is already ${pr.state}; nothing to do.`);
return;
}

await github.rest.issues.createComment({
owner,
repo,
issue_number: number,
body: [
"This pull request was closed automatically by CI.",
"",
"Head branch `jules-docs-dev-*` / `jules-patchnotes-dev-*` is merged by the Jules automation pipeline; an open PR is not required.",
].join("\n"),
});

await github.rest.pulls.update({
owner,
repo,
pull_number: number,
state: "closed",
});

core.info(`Closed PR #${number} (head: ${pr.head.ref}).`);
99 changes: 99 additions & 0 deletions .github/workflows/jules-update-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Copyright NGGT.LightKeeper and Di120078. All Rights Reserved.

name: Jules - Update Docs

on:
push:
branches-ignore:
- 'main'
- 'jules-docs-dev-*'
- 'jules-patchnotes-dev-*'

jobs:
run-jules:
if: github.actor != 'github-actions[bot]'
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
fetch-depth: 2

- name: Jules - Generate Prompt
id: generate-prompt
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%s HEAD)
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
COMMIT_DIFF=$(git diff HEAD~1 HEAD)
# Cap oversized inputs so the request stays within Jules API and shell limits.
CHANGED_FILES=$(printf '%s' "${CHANGED_FILES:0:16384}")
COMMIT_DIFF=$(printf '%s' "${COMMIT_DIFF:0:524288}" | iconv -f UTF-8 -t UTF-8 -c)

PROMPT="The task is created automatically by the CI/CD pipeline system. You are working in the ASLM Code repository. The project contains documentation in the 'Docs/ASLM/' directory based on the Hugo Framework (Lotus Docs theme). Reference pages are under Docs/ASLM/content/docs/ASLM-Code/ and must mirror source paths — preserve directory structure, only change the extension (for example API/mcp.py -> Docs/ASLM/content/docs/ASLM-Code/API/mcp.md; Apps/UI/static/js/main/chat-controller.js -> Docs/ASLM/content/docs/ASLM-Code/Apps/UI/static/js/main/chat-controller.md). Your task is to analyze the commit '${COMMIT_MESSAGE}' and add or update documentation for changed .py and .js files. Never create __init__.md (ignore __init__.py). Study existing documentation before writing and match its style. Do not change any files outside Docs/. Do not touch Docs/ASLM/content/docs/PatchNotes/. If there are no relevant .py/.js changes, make a commit without file changes. Name the output branch jules-docs-dev-BRANCH_NAME where BRANCH_NAME is a short descriptive name; always keep the jules-docs-dev- prefix (example: jules-docs-dev-mcp-update). If there were no relevant changes, use jules-docs-dev-YYYYMMDDHHmm (UTC). This task was created automatically and may have errors; follow the instructions as closely as possible. Modified files: '${CHANGED_FILES}'. Commit diff: '${COMMIT_DIFF}'."

PROMPT_FILE="${RUNNER_TEMP}/jules_prompt.txt"
printf '%s' "$PROMPT" > "$PROMPT_FILE"
echo "prompt_file=$PROMPT_FILE" >> "$GITHUB_OUTPUT"

- name: Jules - Create Session
id: create-session
env:
PROMPT_FILE: ${{ steps.generate-prompt.outputs.prompt_file }}
run: |
JSON_PAYLOAD=$(jq -n \
--rawfile prompt "$PROMPT_FILE" \
--arg source_repo "sources/github/${{ github.repository }}" \
--arg branch "${{ github.ref_name }}" \
--arg title "CI/CD: Update Docs for commit ${{ github.sha }}" \
'{
prompt: $prompt,
sourceContext: {
source: $source_repo,
githubRepoContext: { startingBranch: $branch }
},
title: $title,
automationMode: "AUTO_CREATE_PR"
}')

RESPONSE_JSON=$(curl -s -X POST \
'https://jules.googleapis.com/v1alpha/sessions' \
-H "Content-Type: application/json" \
-H 'X-Goog-Api-Key: ${{ secrets.JULES_API_KEY }}' \
-d "$JSON_PAYLOAD")

SESSION_NAME=$(echo "$RESPONSE_JSON" | jq -r '.name')
echo "Jules session started: $SESSION_NAME"
echo "session_name=$SESSION_NAME" >> $GITHUB_OUTPUT
{
echo 'api_response<<EOF'
echo "$RESPONSE_JSON"
echo 'EOF'
} >> "$GITHUB_OUTPUT"

- name: Jules - Report Result
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SESSION_NAME: ${{ steps.create-session.outputs.session_name }}
API_RESPONSE: ${{ steps.create-session.outputs.api_response }}
run: |
COMMIT_SHA="${{ github.event.after }}"

if [[ -z "$SESSION_NAME" || "$SESSION_NAME" == "null" ]]; then
ERROR=$(echo "$API_RESPONSE" | jq -r '.error.message // "Unknown error"')
COMMENT_BODY="❌ Jules Docs: failed to create session. Error: ${ERROR}"
gh api --method POST -H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/commits/$COMMIT_SHA/comments" \
-f body="$COMMENT_BODY"
exit 1
fi

SESSION_URL="https://jules.google.com/session/$(basename $SESSION_NAME)"
COMMENT_BODY="🚀 Jules Docs session started. Jules will update documentation and open a PR into a \`jules-docs-dev-*\` branch. Track progress: ${SESSION_URL}"
echo "Posting comment: $COMMENT_BODY"
gh api --method POST -H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/commits/$COMMIT_SHA/comments" \
-f body="$COMMENT_BODY"
103 changes: 103 additions & 0 deletions .github/workflows/jules-update-patchnotes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Copyright NGGT.LightKeeper and Di120078. All Rights Reserved.

name: Jules - Update Patch Notes

on:
push:
branches:
- 'jules-docs-dev-*'

jobs:
run-jules:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
fetch-depth: 3

- name: Jules - Generate Prompt
id: generate-prompt
run: |
JULES_DOCS_COMMIT_MESSAGE=$(git log -1 --pretty=%s HEAD)
JULES_DOCS_CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
JULES_DOCS_COMMIT_DIFF=$(git diff HEAD~1 HEAD)

BASE_COMMIT_MESSAGE=$(git log -1 --pretty=%s HEAD~1)
BASE_CHANGED_FILES=$(git diff --name-only HEAD~2 HEAD~1)
BASE_COMMIT_DIFF=$(git diff HEAD~2 HEAD~1)

# Cap oversized inputs so the request stays within Jules API and shell limits.
JULES_DOCS_CHANGED_FILES=$(printf '%s' "${JULES_DOCS_CHANGED_FILES:0:16384}")
JULES_DOCS_COMMIT_DIFF=$(printf '%s' "${JULES_DOCS_COMMIT_DIFF:0:524288}" | iconv -f UTF-8 -t UTF-8 -c)
BASE_CHANGED_FILES=$(printf '%s' "${BASE_CHANGED_FILES:0:16384}")
BASE_COMMIT_DIFF=$(printf '%s' "${BASE_COMMIT_DIFF:0:524288}" | iconv -f UTF-8 -t UTF-8 -c)

PROMPT="The task is created automatically by the CI/CD pipeline system. You are working in the ASLM Code repository. The project contains documentation in the 'Docs/ASLM/' directory based on the Hugo Framework (Lotus Docs theme). This pipeline runs after the Jules documentation pipeline updated docs on a jules-docs-dev-* branch. Your task is to create a Patch Note summarizing changes from the user commit '${BASE_COMMIT_MESSAGE}' and the documentation commit '${JULES_DOCS_COMMIT_MESSAGE}'. Study existing patch notes in Docs/ASLM/content/docs/PatchNotes/ and match their style. Create one new .md file there named YYYYMMDDHHmm-Short-Name.md (YYYYMMDDHHmm = current UTC time). Include Hugo front matter: title, date (RFC3339), draft: false, description. Include sections: ## New Features, ## Bug Fixes, ## API Changes, ## Known Issues. Do not change any files outside Docs/ASLM/content/docs/PatchNotes/. Name the output branch jules-patchnotes-dev-BRANCH_NAME; always keep the jules-patchnotes-dev- prefix (example: jules-patchnotes-dev-mcp-update). If there were no meaningful changes, use jules-patchnotes-dev-YYYYMMDDHHmm (UTC) and an empty commit. This task was created automatically and may have errors; follow the instructions as closely as possible. User commit modified files: '${BASE_CHANGED_FILES}'. User commit diff: '${BASE_COMMIT_DIFF}'. Documentation pipeline modified files: '${JULES_DOCS_CHANGED_FILES}'. Documentation pipeline diff: '${JULES_DOCS_COMMIT_DIFF}'."

PROMPT_FILE="${RUNNER_TEMP}/jules_prompt.txt"
printf '%s' "$PROMPT" > "$PROMPT_FILE"
echo "prompt_file=$PROMPT_FILE" >> "$GITHUB_OUTPUT"

- name: Jules - Create Session
id: create-session
env:
PROMPT_FILE: ${{ steps.generate-prompt.outputs.prompt_file }}
run: |
JSON_PAYLOAD=$(jq -n \
--rawfile prompt "$PROMPT_FILE" \
--arg source_repo "sources/github/${{ github.repository }}" \
--arg branch "${{ github.ref_name }}" \
--arg title "CI/CD: Update Patch Notes for ${{ github.ref_name }}" \
'{
prompt: $prompt,
sourceContext: {
source: $source_repo,
githubRepoContext: { startingBranch: $branch }
},
title: $title,
automationMode: "AUTO_CREATE_PR"
}')

RESPONSE_JSON=$(curl -s -X POST \
'https://jules.googleapis.com/v1alpha/sessions' \
-H "Content-Type: application/json" \
-H 'X-Goog-Api-Key: ${{ secrets.JULES_API_KEY }}' \
-d "$JSON_PAYLOAD")

SESSION_NAME=$(echo "$RESPONSE_JSON" | jq -r '.name')
echo "Jules session started: $SESSION_NAME"
echo "session_name=$SESSION_NAME" >> $GITHUB_OUTPUT
{
echo 'api_response<<EOF'
echo "$RESPONSE_JSON"
echo 'EOF'
} >> "$GITHUB_OUTPUT"

- name: Jules - Report Result
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SESSION_NAME: ${{ steps.create-session.outputs.session_name }}
API_RESPONSE: ${{ steps.create-session.outputs.api_response }}
run: |
COMMIT_SHA="${{ github.event.after }}"

if [[ -z "$SESSION_NAME" || "$SESSION_NAME" == "null" ]]; then
ERROR=$(echo "$API_RESPONSE" | jq -r '.error.message // "Unknown error"')
COMMENT_BODY="❌ Jules Patch Notes: failed to create session. Error: ${ERROR}"
gh api --method POST -H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/commits/$COMMIT_SHA/comments" \
-f body="$COMMENT_BODY"
exit 1
fi

SESSION_URL="https://jules.google.com/session/$(basename $SESSION_NAME)"
COMMENT_BODY="🚀 Jules Patch Notes session started. Jules will create a patch note and open a PR into a \`jules-patchnotes-dev-*\` branch. Track progress: ${SESSION_URL}"
echo "Posting comment: $COMMENT_BODY"
gh api --method POST -H "Accept: application/vnd.github+json" \
"/repos/${{ github.repository }}/commits/$COMMIT_SHA/comments" \
-f body="$COMMENT_BODY"
Loading