Rebuild Bundles on Vapi Update #226
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: Rebuild Bundles on Vapi Update | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs once every 24 hours at midnight UTC | |
workflow_dispatch: # Allows manual triggering of the workflow | |
jobs: | |
rebuild: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout your repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Install npm-check-updates | |
run: npm install -g npm-check-updates | |
- name: Update dependencies | |
run: ncu -u --target latest "@vapi-ai/web" | |
- name: Install dependencies | |
run: npm install | |
- name: Run build script | |
run: npm run build | |
- name: Check for changes | |
id: git_status | |
run: | | |
git add package.json package-lock.json dist/ | |
git diff --cached --quiet || echo "changes=true" >> $GITHUB_ENV | |
- name: Get new version from @vapi-ai/web | |
if: env.changes == 'true' | |
id: get_version | |
run: | | |
echo "new_version=$(jq -r .dependencies[\"@vapi-ai/web\"] package.json | tr -d '^')" >> $GITHUB_ENV | |
- name: Update package.json version | |
if: env.changes == 'true' | |
run: | | |
npm version ${{ env.new_version }} --no-git-tag-version | |
id: update_version | |
- name: Commit and push changes | |
if: env.changes == 'true' | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git commit -m 'Automated build: update dependencies and rebuild bundles' | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create and push tag | |
if: env.changes == 'true' | |
run: | | |
git tag v${{ env.new_version }} | |
git push origin v${{ env.new_version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update latest tag | |
if: env.changes == 'true' | |
run: | | |
git tag -f latest | |
git push -f origin latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |