Update Deepgram SDK #11
Workflow file for this run
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: 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: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install required tools | |
run: sudo apt-get install -y jq curl | |
- name: Get current Deepgram Python SDK version | |
id: get-deepgram-version | |
run: | | |
DEEPGRAM_VERSION=$(curl -s https://api.github.com/repos/deepgram/deepgram-python-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=$(pip show deepgram-sdk | grep Version | cut -d' ' -f2) | |
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" | |
pip install deepgram-sdk==$LATEST_VERSION | |
# Update requirements.txt | |
sed -i "s/deepgram-sdk==.*/deepgram-sdk==$LATEST_VERSION/" requirements.txt | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
# Create a new branch for the update | |
git checkout -b gh/update-deepgram-sdk | |
git add requirements.txt | |
git commit -m "chore: update Deepgram SDK to $LATEST_VERSION" | |
git push -u origin gh/update-deepgram-sdk | |
# Pull latest changes from remote | |
git stash | |
git pull origin main --rebase | |
git stash pop | |
# Check if there are changes to commit | |
if git diff-index --quiet HEAD --; then | |
echo "No changes to commit" | |
else | |
git commit -m "chore: resolve conflicts after update Deepgram SDK to $LATEST_VERSION" | |
git push | |
# Create a pull request | |
gh pr create --title "Update Deepgram SDK to $LATEST_VERSION" --body "Automated update of Deepgram SDK to version $LATEST_VERSION" --head gh/update-deepgram-sdk | |
fi | |
else | |
echo "Deepgram SDK is up to date" | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Install dev dependencies | |
run: pip install -r requirements-dev.txt | |
- name: Run tests | |
id: run-tests | |
env: | |
DEEPGRAM_API_KEY: ${{ secrets.DEEPGRAM_API_KEY }} | |
run: pytest tests/ | |
# - name: Notify on failure | |
# if: failure() | |
# uses: slackapi/slack-github-action@v1.23.0 | |
# with: | |
# payload: | | |
# { | |
# "text": "The tests have FAILED for ${{ github.repository }}." | |
# } | |
# env: | |
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
# - name: Notify on success | |
# if: success() | |
# uses: slackapi/slack-github-action@v1.23.0 | |
# with: | |
# payload: | | |
# { | |
# "text": "The tests have passed for ${{ github.repository }}." | |
# } | |
# env: | |
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |