mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 14:24:13 +08:00
feat: add workflow to sync base-action to claude-code-base-action repo (#299)
* feat: add workflow to sync base-action to claude-code-base-action repo This workflow automatically mirrors the base-action directory to the anthropics/claude-code-base-action repository whenever changes are pushed to base-action files on the main branch. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: add automated release sync to claude-code-base-action - Release workflow now creates matching releases in claude-code-base-action repo - All release jobs now run in production environment - Uses CLAUDE_CODE_BASE_ACTION_PAT for authentication 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
49
.github/workflows/release.yml
vendored
49
.github/workflows/release.yml
vendored
@@ -12,6 +12,7 @@ on:
|
||||
jobs:
|
||||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
environment: production
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
@@ -85,6 +86,7 @@ jobs:
|
||||
needs: create-release
|
||||
if: ${{ !inputs.dry_run }}
|
||||
runs-on: ubuntu-latest
|
||||
environment: production
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
@@ -115,6 +117,7 @@ jobs:
|
||||
needs: create-release
|
||||
if: ${{ !inputs.dry_run }}
|
||||
runs-on: ubuntu-latest
|
||||
environment: production
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
@@ -136,3 +139,49 @@ jobs:
|
||||
git push origin "$major_version" --force
|
||||
|
||||
echo "Updated $major_version tag to point to $next_version"
|
||||
|
||||
release-base-action:
|
||||
needs: create-release
|
||||
if: ${{ !inputs.dry_run }}
|
||||
runs-on: ubuntu-latest
|
||||
environment: production
|
||||
steps:
|
||||
- name: Checkout base-action repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: anthropics/claude-code-base-action
|
||||
token: ${{ secrets.CLAUDE_CODE_BASE_ACTION_PAT }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Create and push tag
|
||||
run: |
|
||||
next_version="${{ needs.create-release.outputs.next_version }}"
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
# Create the version tag
|
||||
git tag -a "$next_version" -m "Release $next_version - synced from claude-code-action"
|
||||
git push origin "$next_version"
|
||||
|
||||
# Update the beta tag
|
||||
git tag -fa beta -m "Update beta tag to ${next_version}"
|
||||
git push origin beta --force
|
||||
|
||||
- name: Create GitHub release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.CLAUDE_CODE_BASE_ACTION_PAT }}
|
||||
run: |
|
||||
next_version="${{ needs.create-release.outputs.next_version }}"
|
||||
|
||||
# Create the release
|
||||
gh release create "$next_version" \
|
||||
--repo anthropics/claude-code-base-action \
|
||||
--title "$next_version" \
|
||||
--notes "Release $next_version - synced from anthropics/claude-code-action" \
|
||||
--latest=false
|
||||
|
||||
# Update beta release to be latest
|
||||
gh release edit beta \
|
||||
--repo anthropics/claude-code-base-action \
|
||||
--latest
|
||||
|
||||
92
.github/workflows/sync-base-action.yml
vendored
Normal file
92
.github/workflows/sync-base-action.yml
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
name: Sync Base Action to claude-code-base-action
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "base-action/**"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
sync-base-action:
|
||||
name: Sync base-action to claude-code-base-action repository
|
||||
runs-on: ubuntu-latest
|
||||
environment: production
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout source repository
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Setup SSH and clone target repository
|
||||
run: |
|
||||
# Configure SSH with deploy key
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.CLAUDE_CODE_BASE_ACTION_REPO_DEPLOY_KEY }}" > ~/.ssh/deploy_key_base
|
||||
chmod 600 ~/.ssh/deploy_key_base
|
||||
|
||||
# Configure SSH host
|
||||
cat > ~/.ssh/config <<EOL
|
||||
Host base-action.github.com
|
||||
HostName github.com
|
||||
User git
|
||||
IdentityFile ~/.ssh/deploy_key_base
|
||||
StrictHostKeyChecking no
|
||||
EOL
|
||||
|
||||
# Clone the target repository
|
||||
git clone git@base-action.github.com:anthropics/claude-code-base-action.git target-repo
|
||||
|
||||
- name: Sync base-action contents
|
||||
run: |
|
||||
cd target-repo
|
||||
|
||||
# Configure git
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
|
||||
# Remove all existing files except .git directory
|
||||
find . -mindepth 1 -maxdepth 1 -name '.git' -prune -o -exec rm -rf {} +
|
||||
|
||||
# Copy all contents from base-action
|
||||
cp -r ../base-action/. .
|
||||
|
||||
# Check if there are any changes
|
||||
if git diff --quiet && git diff --staged --quiet; then
|
||||
echo "No changes to sync"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Stage all changes
|
||||
git add -A
|
||||
|
||||
# Get source commit info for the commit message
|
||||
SOURCE_COMMIT="${GITHUB_SHA:0:7}"
|
||||
SOURCE_COMMIT_MESSAGE=$(git -C .. log -1 --pretty=format:"%s" || echo "Update from base-action")
|
||||
|
||||
# Commit with descriptive message
|
||||
git commit -m "Sync from claude-code-action base-action@${SOURCE_COMMIT}" \
|
||||
-m "" \
|
||||
-m "Source: anthropics/claude-code-action@${GITHUB_SHA}" \
|
||||
-m "Original message: ${SOURCE_COMMIT_MESSAGE}"
|
||||
|
||||
# Push to main branch
|
||||
git push origin main
|
||||
|
||||
echo "Successfully synced base-action to claude-code-base-action"
|
||||
|
||||
- name: Create sync summary
|
||||
if: success()
|
||||
run: |
|
||||
echo "## Sync Summary" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "✅ Successfully synced \`base-action\` directory to [anthropics/claude-code-base-action](https://github.com/anthropics/claude-code-base-action)" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Source commit**: [\`${GITHUB_SHA:0:7}\`](https://github.com/anthropics/claude-code-action/commit/${GITHUB_SHA})" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Triggered by**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Actor**: @${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
|
||||
Reference in New Issue
Block a user