-
Notifications
You must be signed in to change notification settings - Fork 2
148 lines (131 loc) · 5.51 KB
/
sync-whisper.yml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: 🤫 Sync whisper.cpp
on:
workflow_dispatch:
inputs:
tag_override:
description: 'Override the latest tag (optional)'
required: false
default: ''
schedule:
- cron: '0 0 * * *'
permissions:
contents: write
jobs:
sync-by-tag:
name: 🏷️ Sync Repository by Latest Tag
runs-on: ubuntu-latest
if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule')
steps:
- name: 🏷️ Determine the tag to use
run: |
if [[ -z "${{ github.event.inputs.tag_override }}" ]]; then
LATEST_TAG=$(git ls-remote --tags --sort="v:refname" https://github.com/ggerganov/whisper.cpp.git | tail -n1 | sed 's/.*refs\/tags\///; s/\^{}//')
else
LATEST_TAG=${{ github.event.inputs.tag_override }}
fi
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: 🛒 Checkout main repository for TARGET_REPOSITORY
run: |
git clone https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }} $HOME/TARGET_REPOSITORY
- name: 🔀 Create/Checkout the branch by NAME
run: |
cd $HOME/TARGET_REPOSITORY
git fetch origin
echo "Latest Branch Name: $LATEST_TAG"
# Check if branch exists on local.
if git show-ref --verify --quiet refs/heads/$LATEST_TAG; then
echo "Branch exists locally, checking out."
git checkout $LATEST_TAG
else
echo "Branch does not exist locally. Checking if it exists in the remote."
# Check if branch exists on remote.
if git ls-remote --heads origin | grep $LATEST_TAG; then
echo "Branch found in remote, checking out."
git checkout -b $LATEST_TAG origin/$LATEST_TAG
else
echo "Branch not found in remote, creating a new one from origin/main."
git checkout -b $LATEST_TAG origin/main
# No need to reset the branch if it's newly created from origin/main.
fi
fi
- name: 🧹 Clean TARGET_REPOSITORY (keep .git)
run: |
cd $HOME/TARGET_REPOSITORY
shopt -s extglob
rm -rf !(.|..|.git)
- name: 🛒 Checkout main repository for MAIN_REPOSITORY
run: |
git clone https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }} $HOME/MAIN_REPOSITORY
- name: 🗑️ Clean MAIN_REPOSITORY (remove .git and whisper)
run: |
cd $HOME/MAIN_REPOSITORY
shopt -s extglob
rm -rf .git
rm -rf src/whisper
- name: 🔄 Sync MAIN_REPOSITORY to TARGET_REPOSITORY
run: |
cd $HOME/MAIN_REPOSITORY
shopt -s dotglob
rsync -av --progress $HOME/MAIN_REPOSITORY/ $HOME/TARGET_REPOSITORY/
- name: 🔄 Clone whisper.cpp by tag
run: |
git clone --branch $LATEST_TAG --depth 1 https://github.com/ggerganov/whisper.cpp.git $HOME/LATEST_TAG_WHISPER_CPP
- name: 🧼 Clean LATEST_TAG_WHISPER_CPP (remove unnecessary files)
run: |
cd $HOME/LATEST_TAG_WHISPER_CPP
shopt -s extglob
rm -rf .git
rm -rf .devops
rm -rf .github
rm -rf docs
rm -rf samples
rm -f LICENSE
rm -f .gitignore
rm -f .gitmodules
find . -name "*.md" -exec rm {} \;
find . -name "*.txt" -exec rm {} \;
- name: 🚚 Move LATEST_TAG_WHISPER_CPP to TARGET_REPOSITORY/src/whisper
run: |
cd $HOME/LATEST_TAG_WHISPER_CPP
shopt -s dotglob
mkdir -p $HOME/TARGET_REPOSITORY/src/whisper
mv -f * $HOME/TARGET_REPOSITORY/src/whisper
- name: 💾 Commit and push changes to TARGET_REPOSITORY
run: |
cd $HOME/TARGET_REPOSITORY
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add --all
git diff --quiet && git diff --staged --quiet || (git commit -m "Sync with whisper.cpp $LATEST_TAG 🚀" && git push --set-upstream origin $LATEST_TAG)
sync-latest-commit:
name: 🔄 Sync Repository with Latest Commit
runs-on: ubuntu-latest
if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule')
steps:
- name: 🛒 Checkout repository for sync
run: |
git clone https://x-access-token:${{ secrets.PAT }}@github.com/ErcinDedeoglu/WhisperDock.git .
- name: 🔄 Sync whisper.cpp repository to src/whisper
run: |
mkdir -p src
rm -rf src/whisper
git clone https://github.com/ggerganov/whisper.cpp.git src/whisper
rm -rf src/whisper/.git
rm -rf src/whisper/.devops
rm -rf src/whisper/.github
rm -rf src/whisper/docs
rm -rf src/whisper/samples
rm -f src/whisper/LICENSE
rm -f src/whisper/.gitignore
rm -f src/whisper/.gitmodules
find src/whisper -name "*.md" -exec rm {} \;
find src/whisper -name "*.txt" -exec rm {} \;
- name: 💾 Commit and push sync changes
run: |
git config --local user.name 'github-actions[bot]'
git config --local user.email 'github-actions[bot]@users.noreply.github.com'
git add src/whisper
git commit -m "Sync with whisper.cpp 🚀" -a || echo "No changes to commit 🛑"
git push origin 'main'
env:
GITHUB_TOKEN: ${{ secrets.PAT }}