Skip to content

Commit a2b9cd9

Browse files
committed
fix: delete and re-create by-database branch on each commit
1 parent eed5c0e commit a2b9cd9

1 file changed

Lines changed: 16 additions & 30 deletions

File tree

‎.github/workflows/restructure.yml‎

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,49 +45,35 @@ jobs:
4545
--source source \
4646
--output restructured
4747
48-
- name: Checkout target branch
49-
uses: actions/checkout@v6
50-
with:
51-
ref: by-database
52-
path: target
53-
fetch-depth: 0
54-
continue-on-error: true
55-
56-
- name: Create orphan branch if needed
48+
- name: Delete target branch
5749
run: |
58-
if [ ! -d "target/.git" ]; then
59-
mkdir -p target
60-
cd target
61-
git init
62-
git checkout --orphan by-database
63-
fi
64-
65-
- name: Update target branch
50+
git push origin --delete by-database || true
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Create and push orphan branch
6655
run: |
67-
# Clear target directory (except .git)
56+
mkdir target
6857
cd target
69-
find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
70-
58+
git init
59+
git checkout --orphan by-database
60+
7161
# Copy restructured content
7262
cp -r ../restructured/* .
73-
63+
7464
# Configure git
7565
git config user.name "github-actions[bot]"
7666
git config user.email "github-actions[bot]@users.noreply.github.com"
77-
67+
7868
# Commit and push
7969
git add -A
80-
81-
if git diff --cached --quiet; then
82-
echo "No changes to commit"
83-
else
84-
git commit -m "Restructure repository (by-database view)
70+
git commit -m "Restructure repository (by-database view)
8571
8672
Source commit: ${{ github.sha }}
8773
Triggered by: ${{ github.event_name }}"
88-
89-
git push origin by-database --force
90-
fi
74+
75+
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
76+
git push origin by-database
9177
env:
9278
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9379

0 commit comments

Comments
 (0)