Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 9, 2023
1 parent a25f97f commit 06d6bd0
Showing 1 changed file with 59 additions and 20 deletions.
79 changes: 59 additions & 20 deletions .github/workflows/sync-whisper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,89 @@ jobs:
runs-on: ubuntu-latest
if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule')
steps:
- name: 🛒 Checkout main repository using native git
run: git clone https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }} .
env:
PAT: ${{ secrets.PAT }}

- 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 }} /TARGET_REPOSITORY
env:
PAT: ${{ secrets.PAT }}

- name: 🔀 Create a new branch for the latest tag or checkout if it exists
- name: 🔀 Create/Checout the branch by TAG
run: |
cd /TARGET_REPOSITORY
git checkout -b $LATEST_TAG || git checkout $LATEST_TAG
env:
LATEST_TAG: ${{ env.LATEST_TAG }}

- name: 🔄 Sync whisper.cpp repository
- name: Remove everything except for the .git folder in /TARGET_REPOSITORY
run: |
# Assuming the current directory is the root of the repository
# Remove everything except for the .git folder
cd /TARGET_REPOSITORY
shopt -s extglob
rm -rf !(.|..|.git)
# Clone the specific tag of whisper.cpp repository into a temporary directory
git clone --branch $LATEST_TAG --depth 1 https://github.com/ggerganov/whisper.cpp.git temp_dir
# Copy everything from temp_dir excluding the .git folder
- name: 🛒 Checkout main repository for /MAIN_REPOSITORY
run: git clone https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }} /MAIN_REPOSITORY
env:
PAT: ${{ secrets.PAT }}

- name: Remove whisper, .git folders in /MAIN_REPOSITORY
run: |
cd /MAIN_REPOSITORY
shopt -s extglob
rm -rf .git
rm -rf src/whisper
- name: Move content of /MAIN_REPOSITORY to /TARGET_REPOSITORY
run: |
cd /MAIN_REPOSITORY
shopt -s dotglob
mv temp_dir/* .
# Clean up the temporary directory
rm -rf temp_dir
mv -f * /TARGET_REPOSITORY
- name: 🔄 Clone whisper.cpp by tag
run: |
git clone --branch $LATEST_TAG --depth 1 https://github.com/ggerganov/whisper.cpp.git /LATEST_TAG_WHISPER_CPP
env:
LATEST_TAG: ${{ env.LATEST_TAG }}

- name: Remove unnecessary files/folders in /LATEST_TAG_WHISPER_CPP folder
run: |
cd /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 /LATEST_TAG_WHISPER_CPP
shopt -s dotglob
mkdir -p /TARGET_REPOSITORY/src/whisper
mv -f * /TARGET_REPOSITORY/src/whisper
- name: 💾 Commit and push changes
run: |
git config --local user.email "action@github.com"
cd /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 }}
PAT: ${{ secrets.PAT }}


sync-latest-commit:
name: 🔄 Sync Repository with Latest Commit
runs-on: ubuntu-latest
Expand Down

0 comments on commit 06d6bd0

Please sign in to comment.