Skip to content

Update Deepgram SDK

Update Deepgram SDK #6

name: Update Deepgram SDK
on:
schedule:
- cron: '0 0 * * 1' # Runs every Monday at midnight
workflow_dispatch:
jobs:
check-update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install jq
run: sudo apt-get install -y jq
- name: Get current Deepgram JS SDK version
id: get-deepgram-version
run: |
DEEPGRAM_VERSION=$(curl -s https://api.github.com/repos/deepgram/deepgram-js-sdk/releases/latest | jq -r '.tag_name')
echo "version=$DEEPGRAM_VERSION" >> $GITHUB_ENV
- name: Check installed Deepgram SDK version
id: check-installed-version
run: |
INSTALLED_VERSION=$(jq -r '.dependencies["@deepgram/sdk"]' package.json | tr -d '^v')
echo "installed_version=$INSTALLED_VERSION" >> $GITHUB_ENV
- name: Compare versions and update if necessary
run: |
LATEST_VERSION=${{ env.version }}
INSTALLED_VERSION=${{ env.installed_version }}
if [ "$LATEST_VERSION" != "$INSTALLED_VERSION" ]; then
echo "Updating Deepgram SDK from $INSTALLED_VERSION to $LATEST_VERSION"
npm install @deepgram/sdk@$LATEST_VERSION
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add package.json package-lock.json
git commit -m "chore: update Deepgram SDK to $LATEST_VERSION"
git push
else
echo "Deepgram SDK is up to date"
- name: Install dependencies
run: npm install
- name: Run tests
id: run-tests
run: |
npm run test
- name: Notify on failure
if: failure()
uses: slackapi/[email protected]
with:
payload: |
{
"text": "The tests have failed in the recent GitHub Actions run."
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Notify on success
if: success()
uses: slackapi/[email protected]
with:
payload: |
{
"text": "The tests have passed for ${{ github.repository }}."
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}