fix: improve GitHub mirror workflow reliability
- Added workflow_dispatch for manual triggering - Added debugging steps to identify issues - Clean up existing branches before creating new ones - Remove existing remotes to avoid conflicts - Added GitHub token verification - Added completion status messages - Made workflow more resilient with better error handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
workflow_dispatch: # Allow manual triggering
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
mirror:
|
mirror:
|
||||||
@@ -19,11 +20,22 @@ jobs:
|
|||||||
git config --global user.name "the-luap"
|
git config --global user.name "the-luap"
|
||||||
git config --global user.email "paul-nothaft@hotmail.de"
|
git config --global user.email "paul-nothaft@hotmail.de"
|
||||||
|
|
||||||
|
- name: Debug - Show current branch and status
|
||||||
|
run: |
|
||||||
|
echo "Current branch:"
|
||||||
|
git branch -a
|
||||||
|
echo "Git status:"
|
||||||
|
git status
|
||||||
|
echo "Remote info:"
|
||||||
|
git remote -v
|
||||||
|
|
||||||
- name: Create filtered branch
|
- name: Create filtered branch
|
||||||
run: |
|
run: |
|
||||||
|
# Clean up any existing github-mirror branch
|
||||||
|
git branch -D github-mirror || true
|
||||||
|
|
||||||
# Create a new branch for GitHub
|
# Create a new branch for GitHub
|
||||||
git checkout --orphan -b github-mirror
|
git checkout --orphan github-mirror
|
||||||
|
|
||||||
# Remove sensitive files/directories
|
# Remove sensitive files/directories
|
||||||
# Example: Remove .env files, private configs, etc.
|
# Example: Remove .env files, private configs, etc.
|
||||||
@@ -48,12 +60,37 @@ jobs:
|
|||||||
# Commit the changes
|
# Commit the changes
|
||||||
git commit -m "Remove sensitive files for GitHub mirror" || true
|
git commit -m "Remove sensitive files for GitHub mirror" || true
|
||||||
|
|
||||||
|
- name: Check GitHub token
|
||||||
|
env:
|
||||||
|
GITHUBTOKEN: ${{ secrets.GITHUBTOKEN }}
|
||||||
|
run: |
|
||||||
|
if [ -z "$GITHUBTOKEN" ]; then
|
||||||
|
echo "ERROR: GITHUBTOKEN secret is not set!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "GitHub token is available (length: ${#GITHUBTOKEN})"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Push to GitHub
|
- name: Push to GitHub
|
||||||
env:
|
env:
|
||||||
GITHUBTOKEN: ${{ secrets.GITHUBTOKEN }}
|
GITHUBTOKEN: ${{ secrets.GITHUBTOKEN }}
|
||||||
run: |
|
run: |
|
||||||
|
# Remove existing github remote if it exists
|
||||||
|
git remote remove github || true
|
||||||
|
|
||||||
# Add GitHub remote
|
# Add GitHub remote
|
||||||
git remote add github https://x-access-token:${GITHUBTOKEN}@github.com/the-luap/picpeak.git
|
git remote add github https://x-access-token:${GITHUBTOKEN}@github.com/the-luap/picpeak.git
|
||||||
|
|
||||||
|
# Verify remote was added
|
||||||
|
echo "GitHub remote added:"
|
||||||
|
git remote -v
|
||||||
|
|
||||||
# Force push the filtered branch to GitHub main
|
# Force push the filtered branch to GitHub main
|
||||||
git push github github-mirror:main --force
|
echo "Pushing to GitHub..."
|
||||||
|
git push github github-mirror:main --force
|
||||||
|
echo "Push completed successfully!"
|
||||||
|
|
||||||
|
- name: Workflow completed
|
||||||
|
run: |
|
||||||
|
echo "✅ Mirror to GitHub workflow completed successfully!"
|
||||||
|
echo "Check https://github.com/the-luap/picpeak to verify the mirror."
|
||||||
Reference in New Issue
Block a user