🤫 Sync whisper.cpp #66
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 🤫 Sync whisper.cpp | |
on: | |
workflow_dispatch: | |
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: 🏷️ Get latest tag name from the external repository | |
run: | | |
LATEST_TAG=$(git ls-remote --tags --sort="v:refname" https://github.com/ggerganov/whisper.cpp.git | tail -n1 | sed 's/.*refs\/tags\///; s/\^{}//') | |
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV | |
env: | |
LATEST_TAG: ${{ env.LATEST_TAG }} | |
- name: 🛒 Checkout main repository for /TARGET_REPOSITORY | |
run: git clone https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }} $HOME/TARGET_REPOSITORY | |
env: | |
PAT: ${{ secrets.PAT }} | |
- name: 🔀 Create/Checout the branch by TAG | |
run: | | |
cd $HOME/TARGET_REPOSITORY | |
git checkout -b $LATEST_TAG || git checkout $LATEST_TAG | |
env: | |
LATEST_TAG: ${{ env.LATEST_TAG }} | |
- name: Remove everything except for the .git folder in /TARGET_REPOSITORY | |
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 | |
env: | |
PAT: ${{ secrets.PAT }} | |
- name: Remove whisper, .git folders in /MAIN_REPOSITORY | |
run: | | |
cd $HOME/MAIN_REPOSITORY | |
shopt -s extglob | |
rm -rf .git | |
rm -rf src/whisper | |
- name: Move content of /MAIN_REPOSITORY to /TARGET_REPOSITORY | |
run: | | |
cd $HOME/MAIN_REPOSITORY | |
shopt -s dotglob | |
mv -f * $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 | |
env: | |
LATEST_TAG: ${{ env.LATEST_TAG }} | |
- name: Remove unnecessary files/folders in /LATEST_TAG_WHISPER_CPP folder | |
run: | | |
cd $HOME/LATEST_TAG | |
shopt -s extglob | |
rm -rf .git | |
rm -rf .devops | |
rm -rf .github | |
rm -rf docs | |
rm -rf tests | |
rm -rf samples | |
rm -f LICENSE | |
rm -f .gitignore | |
rm -f .gitmodules | |
find . -name "*.md" -exec rm {} \; | |
find . -name "*.txt" -exec rm {} \; | |
- name: Move content of /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 | |
run: | | |
cd $HOME/TARGET_REPOSITORY | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "GitHub Action" | |
git add . | |
git commit -m "Sync with whisper.cpp $LATEST_TAG" | |
git push --set-upstream origin $LATEST_TAG | |
env: | |
LATEST_TAG: ${{ env.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 | |
run: | | |
git clone https://x-access-token:${{ secrets.PAT }}@github.com/ErcinDedeoglu/stt.git . | |
env: | |
PAT: ${{ secrets.PAT }} | |
- name: 🔄 Sync whisper.cpp repository | |
run: | | |
# The target directory is 'src/whisper' | |
mkdir -p src | |
rm -rf src/whisper # Remove the directory if it exists | |
git clone https://github.com/ggerganov/whisper.cpp.git src/whisper | |
# Remove the .git directory and other unwanted files | |
rm -rf src/whisper/.git | |
rm -rf src/whisper/.devops | |
rm -rf src/whisper/.github | |
rm -rf src/whisper/docs | |
rm -rf src/whisper/tests | |
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 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 ggerganov/whisper.cpp" -a || echo "No changes to commit" | |
git push origin 'main' | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} |