feat: migrate workflows to kcl-ci standard
- Add .forgejo/kcl-ci/ with kcl.mod, main.k, Taskfile.yaml - claude.yml: use claude.k module (fixes #comment YAML validation error, removes duplicate pull_request_comment trigger) - ci.yml: add paths-ignore for kcl-ci paths, named jobs for check constants - test-action.yml: regenerated from KCL (functionally identical) - upstream-sync.yml: regenerated from KCL (functionally identical) - kcl-ci-build.yml: new auto-regeneration workflow (waits for CI checks) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
8125818e24
commit
5c014823e0
9 files changed
+821
-383
No files matched your search
@@ -1,176 +1,166 @@
|
||||
# Generated by KCL v1.34.3 - DO NOT EDIT
|
||||
# Source: .forgejo/kcl-ci/main.k
|
||||
# kcl-ci local: ~/stuff/gitrepos/wxs/actions/kcl-ci
|
||||
# kcl-ci remote: https://git.wxs.ro/actions/kcl-ci
|
||||
|
||||
name: Upstream Sync Check
|
||||
|
||||
on:
|
||||
'on':
|
||||
schedule:
|
||||
# Weekly Monday at 08:00 UTC
|
||||
- cron: "0 8 * * 1"
|
||||
workflow_dispatch:
|
||||
|
||||
- cron: '0 8 * * 1'
|
||||
workflow_dispatch: {}
|
||||
jobs:
|
||||
check-upstream:
|
||||
name: Check for upstream updates
|
||||
runs-on: grunt
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://${{ secrets.READ_REPO_TOKEN }}@git.wxs.ro/xternal/checkout@v6.0.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Checkout
|
||||
uses: https://${{ secrets.READ_REPO_TOKEN }}@git.wxs.ro/xternal/checkout@v6.0.2
|
||||
with:
|
||||
fetch-depth: '0'
|
||||
- name: Configure upstream remote
|
||||
run: |-
|
||||
if ! git remote get-url upstream &> /dev/null; then
|
||||
git remote add upstream https://github.com/anthropics/claude-code-action.git
|
||||
fi
|
||||
- name: Fetch upstream
|
||||
run: git fetch upstream main --quiet
|
||||
- name: Compare with upstream
|
||||
id: compare
|
||||
run: |-
|
||||
BEHIND_COUNT=$(git rev-list main..upstream/main --count)
|
||||
AHEAD_COUNT=$(git rev-list upstream/main..main --count)
|
||||
|
||||
- name: Configure upstream remote
|
||||
run: |
|
||||
if ! git remote get-url upstream &> /dev/null; then
|
||||
git remote add upstream https://github.com/anthropics/claude-code-action.git
|
||||
fi
|
||||
echo "behind=$BEHIND_COUNT" >> "$GITHUB_OUTPUT"
|
||||
echo "ahead=$AHEAD_COUNT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Fetch upstream
|
||||
run: git fetch upstream main --quiet
|
||||
echo "Our main is $BEHIND_COUNT commits behind and $AHEAD_COUNT commits ahead of upstream"
|
||||
|
||||
- name: Compare with upstream
|
||||
id: compare
|
||||
run: |
|
||||
BEHIND_COUNT=$(git rev-list main..upstream/main --count)
|
||||
AHEAD_COUNT=$(git rev-list upstream/main..main --count)
|
||||
if [ "$BEHIND_COUNT" -gt 0 ]; then
|
||||
echo "needs_sync=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
echo "behind=$BEHIND_COUNT" >> "$GITHUB_OUTPUT"
|
||||
echo "ahead=$AHEAD_COUNT" >> "$GITHUB_OUTPUT"
|
||||
echo "--- New upstream commits ---"
|
||||
git log main..upstream/main --oneline | head -30
|
||||
|
||||
echo "Our main is $BEHIND_COUNT commits behind and $AHEAD_COUNT commits ahead of upstream"
|
||||
echo ""
|
||||
echo "--- Files changed ---"
|
||||
DIFF_STAT=$(git diff --stat main...upstream/main)
|
||||
echo "$DIFF_STAT"
|
||||
|
||||
if [ "$BEHIND_COUNT" -gt 0 ]; then
|
||||
echo "needs_sync=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Generate diff summary
|
||||
echo "--- New upstream commits ---"
|
||||
git log main..upstream/main --oneline | head -30
|
||||
|
||||
echo ""
|
||||
echo "--- Files changed ---"
|
||||
DIFF_STAT=$(git diff --stat main...upstream/main)
|
||||
{
|
||||
echo "diff_stat<<DIFF_EOF"
|
||||
echo "$DIFF_STAT"
|
||||
echo "DIFF_EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Save for issue body (escape newlines for multiline output)
|
||||
{
|
||||
echo "diff_stat<<DIFF_EOF"
|
||||
echo "$DIFF_STAT"
|
||||
echo "DIFF_EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
{
|
||||
echo "commit_log<<LOG_EOF"
|
||||
git log main..upstream/main --oneline | head -30
|
||||
echo "LOG_EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "needs_sync=false" >> "$GITHUB_OUTPUT"
|
||||
echo "Already up to date with upstream"
|
||||
fi
|
||||
- name: Check for existing sync issue
|
||||
if: steps.compare.outputs.needs_sync == 'true'
|
||||
id: existing
|
||||
run: |-
|
||||
RESPONSE=$(curl -s \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ github.repository }}/issues?state=open&labels=upstream-sync&limit=1")
|
||||
|
||||
{
|
||||
echo "commit_log<<LOG_EOF"
|
||||
git log main..upstream/main --oneline | head -30
|
||||
echo "LOG_EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "needs_sync=false" >> "$GITHUB_OUTPUT"
|
||||
echo "Already up to date with upstream"
|
||||
fi
|
||||
ISSUE_COUNT=$(echo "$RESPONSE" | jq 'length')
|
||||
|
||||
- name: Check for existing sync issue
|
||||
if: steps.compare.outputs.needs_sync == 'true'
|
||||
id: existing
|
||||
run: |
|
||||
# Search for open issues with the upstream-sync label
|
||||
RESPONSE=$(curl -s \
|
||||
if [ "$ISSUE_COUNT" -gt 0 ]; then
|
||||
ISSUE_NUMBER=$(echo "$RESPONSE" | jq '.[0].number')
|
||||
echo "issue_exists=true" >> "$GITHUB_OUTPUT"
|
||||
echo "issue_number=$ISSUE_NUMBER" >> "$GITHUB_OUTPUT"
|
||||
echo "Found existing sync issue #$ISSUE_NUMBER"
|
||||
else
|
||||
echo "issue_exists=false" >> "$GITHUB_OUTPUT"
|
||||
echo "No existing sync issue found"
|
||||
fi
|
||||
- name: Create upstream-sync label
|
||||
if: steps.compare.outputs.needs_sync == 'true'
|
||||
run: |-
|
||||
curl -s -o /dev/null -w "%{http_code}" \
|
||||
-X POST \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"upstream-sync","color":"#0075ca","description":"Upstream sync tracking"}' \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ github.repository }}/labels" || true
|
||||
- name: Create or update sync issue
|
||||
if: steps.compare.outputs.needs_sync == 'true'
|
||||
run: |-
|
||||
BEHIND="${{ steps.compare.outputs.behind }}"
|
||||
AHEAD="${{ steps.compare.outputs.ahead }}"
|
||||
COMMIT_LOG=$(cat <<'LOG_EOF'
|
||||
${{ steps.compare.outputs.commit_log }}
|
||||
LOG_EOF
|
||||
)
|
||||
DIFF_STAT=$(cat <<'DIFF_EOF'
|
||||
${{ steps.compare.outputs.diff_stat }}
|
||||
DIFF_EOF
|
||||
)
|
||||
|
||||
BODY=$(cat <<BODY_EOF
|
||||
## Upstream Sync Required
|
||||
|
||||
Our \`main\` branch is **${BEHIND} commits behind** upstream (\`anthropics/claude-code-action\`).
|
||||
We are **${AHEAD} commits ahead** (our Forgejo-specific changes).
|
||||
|
||||
### New upstream commits (latest ${BEHIND}, max 30 shown)
|
||||
|
||||
\`\`\`
|
||||
${COMMIT_LOG}
|
||||
\`\`\`
|
||||
|
||||
### Files changed
|
||||
|
||||
\`\`\`
|
||||
${DIFF_STAT}
|
||||
\`\`\`
|
||||
|
||||
### How to merge
|
||||
|
||||
\`\`\`bash
|
||||
git fetch upstream main
|
||||
git merge upstream/main
|
||||
# Resolve any conflicts in the 3-4 modified files (run.ts, tag/index.ts, etc.)
|
||||
bun test
|
||||
git push origin main
|
||||
\`\`\`
|
||||
|
||||
### Conflict-prone files
|
||||
|
||||
These files have Forgejo modifications and may conflict:
|
||||
- \`src/entrypoints/run.ts\`
|
||||
- \`src/modes/tag/index.ts\`
|
||||
- \`src/mcp/install-mcp-server.ts\`
|
||||
- \`action.yml\`
|
||||
|
||||
_Auto-generated by upstream-sync workflow on $(date -u +%Y-%m-%d)_
|
||||
BODY_EOF
|
||||
)
|
||||
|
||||
TITLE="Upstream sync: ${BEHIND} new commits from anthropics/claude-code-action"
|
||||
|
||||
if [ "${{ steps.existing.outputs.issue_exists }}" = "true" ]; then
|
||||
ISSUE_NUMBER="${{ steps.existing.outputs.issue_number }}"
|
||||
curl -s -o /dev/null \
|
||||
-X PATCH \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${GITHUB_API_URL}/repos/${{ github.repository }}/issues?state=open&labels=upstream-sync&limit=1")
|
||||
|
||||
ISSUE_COUNT=$(echo "$RESPONSE" | jq 'length')
|
||||
|
||||
if [ "$ISSUE_COUNT" -gt 0 ]; then
|
||||
ISSUE_NUMBER=$(echo "$RESPONSE" | jq '.[0].number')
|
||||
echo "issue_exists=true" >> "$GITHUB_OUTPUT"
|
||||
echo "issue_number=$ISSUE_NUMBER" >> "$GITHUB_OUTPUT"
|
||||
echo "Found existing sync issue #$ISSUE_NUMBER"
|
||||
else
|
||||
echo "issue_exists=false" >> "$GITHUB_OUTPUT"
|
||||
echo "No existing sync issue found"
|
||||
fi
|
||||
|
||||
- name: Create upstream-sync label
|
||||
if: steps.compare.outputs.needs_sync == 'true'
|
||||
run: |
|
||||
# Create label if it doesn't exist (ignore 409 conflict)
|
||||
curl -s -o /dev/null -w "%{http_code}" \
|
||||
-d "$(jq -n --arg title "$TITLE" --arg body "$BODY" '{title: $title, body: $body}')" \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ github.repository }}/issues/${ISSUE_NUMBER}"
|
||||
echo "Updated existing issue #${ISSUE_NUMBER}"
|
||||
else
|
||||
curl -s -o /dev/null \
|
||||
-X POST \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"upstream-sync","color":"#0075ca","description":"Upstream sync tracking"}' \
|
||||
"${GITHUB_API_URL}/repos/${{ github.repository }}/labels" || true
|
||||
|
||||
- name: Create or update sync issue
|
||||
if: steps.compare.outputs.needs_sync == 'true'
|
||||
run: |
|
||||
BEHIND="${{ steps.compare.outputs.behind }}"
|
||||
AHEAD="${{ steps.compare.outputs.ahead }}"
|
||||
COMMIT_LOG=$(cat <<'LOG_EOF'
|
||||
${{ steps.compare.outputs.commit_log }}
|
||||
LOG_EOF
|
||||
)
|
||||
DIFF_STAT=$(cat <<'DIFF_EOF'
|
||||
${{ steps.compare.outputs.diff_stat }}
|
||||
DIFF_EOF
|
||||
)
|
||||
|
||||
BODY=$(cat <<BODY_EOF
|
||||
## Upstream Sync Required
|
||||
|
||||
Our \`main\` branch is **${BEHIND} commits behind** upstream (\`anthropics/claude-code-action\`).
|
||||
We are **${AHEAD} commits ahead** (our Forgejo-specific changes).
|
||||
|
||||
### New upstream commits (latest ${BEHIND}, max 30 shown)
|
||||
|
||||
\`\`\`
|
||||
${COMMIT_LOG}
|
||||
\`\`\`
|
||||
|
||||
### Files changed
|
||||
|
||||
\`\`\`
|
||||
${DIFF_STAT}
|
||||
\`\`\`
|
||||
|
||||
### How to merge
|
||||
|
||||
\`\`\`bash
|
||||
git fetch upstream main
|
||||
git merge upstream/main
|
||||
# Resolve any conflicts in the 3-4 modified files (run.ts, tag/index.ts, etc.)
|
||||
bun test
|
||||
git push origin main
|
||||
\`\`\`
|
||||
|
||||
### Conflict-prone files
|
||||
|
||||
These files have Forgejo modifications and may conflict:
|
||||
- \`src/entrypoints/run.ts\`
|
||||
- \`src/modes/tag/index.ts\`
|
||||
- \`src/mcp/install-mcp-server.ts\`
|
||||
- \`action.yml\`
|
||||
|
||||
_Auto-generated by upstream-sync workflow on $(date -u +%Y-%m-%d)_
|
||||
BODY_EOF
|
||||
)
|
||||
|
||||
TITLE="Upstream sync: ${BEHIND} new commits from anthropics/claude-code-action"
|
||||
|
||||
if [ "${{ steps.existing.outputs.issue_exists }}" = "true" ]; then
|
||||
# Update existing issue
|
||||
ISSUE_NUMBER="${{ steps.existing.outputs.issue_number }}"
|
||||
curl -s -o /dev/null \
|
||||
-X PATCH \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$(jq -n --arg title "$TITLE" --arg body "$BODY" '{title: $title, body: $body}')" \
|
||||
"${GITHUB_API_URL}/repos/${{ github.repository }}/issues/${ISSUE_NUMBER}"
|
||||
echo "Updated existing issue #${ISSUE_NUMBER}"
|
||||
else
|
||||
# Create new issue
|
||||
curl -s -o /dev/null \
|
||||
-X POST \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$(jq -n --arg title "$TITLE" --arg body "$BODY" '{title: $title, body: $body, labels: [{"name": "upstream-sync"}]}')" \
|
||||
"${GITHUB_API_URL}/repos/${{ github.repository }}/issues"
|
||||
echo "Created new upstream sync issue"
|
||||
fi
|
||||
-d "$(jq -n --arg title "$TITLE" --arg body "$BODY" '{title: $title, body: $body, labels: [{"name": "upstream-sync"}]}')" \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ github.repository }}/issues"
|
||||
echo "Created new upstream sync issue"
|
||||
fi
|
||||
Reference in new issue
Block a user