-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (48 loc) · 2.21 KB
/
update gh-pages.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Update GH pages
on:
push:
branches-ignore:
- 'subm-pretest/**'
workflow_dispatch:
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: false
jobs:
update-gh-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- run: |
git config --global core.autocrlf false
git config --global user.name "sun pack bot"
git config --global user.email "[email protected]"
git config --global --add url.https://github.com/.insteadOf "[email protected]:"
git fetch origin
for branch in $(git branch -r | grep 'origin/gh-pages/'); do
branch_name=$(echo $branch | sed 's#origin/gh-pages/##')
echo "Testing legacy branch [$branch]"
if ! git branch -r | grep -q "origin/$branch_name"; then
echo "Deleting legacy branch [$branch]"
git push origin --delete $(echo $branch | sed 's#origin/##')
fi
done
branch_name="gh-pages/$(git rev-parse --abbrev-ref HEAD)"
git checkout --orphan "$branch_name"
mv ".git" "Packing/Reference/0Release/"
cd "Packing/Reference/0Release/"
git add .
git commit -m "Split off gh-pages"
if git show-ref --verify --quiet refs/remotes/origin/$branch_name; then
echo "Remote branch $branch_name found"
if [ -z "$( git diff "origin/$branch_name" )" ]; then
echo "No difference with remote branch"
exit 0
else
echo "Difference found, recreating the branch"
fi
else
echo "Creating new remote branch"
fi
git push -f --set-upstream origin "$branch_name"