generated from deepgram-starters/project-template
-
Notifications
You must be signed in to change notification settings - Fork 23
105 lines (87 loc) · 3.58 KB
/
update-deepgram-sdk.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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: Config git
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_ACCESS_TOKEN }}
shell: bash
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global init.defaultBranch main
git config --global pull.rebase true
git config --global url."https://git:[email protected]".insteadOf "https://github.com"
- name: Compare versions and update if necessary
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_ACCESS_TOKEN }}
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 add requirements.txt
# Create a new branch and commit changes
BRANCH_NAME="update-deepgram-sdk-$LATEST_VERSION"
git checkout -b "$BRANCH_NAME"
git commit -m "chore: update Deepgram SDK to $LATEST_VERSION"
# Push the new branch and create a PR
git push origin "$BRANCH_NAME"
gh pr create --title "chore: update Deepgram SDK to $LATEST_VERSION" --body "This PR updates the Deepgram SDK to version $LATEST_VERSION." --base "main" --head "$BRANCH_NAME"
else
echo "Deepgram SDK is up to date"
fi
- name: Install dependencies
run: pip install -r requirements.txt
- name: Install dev dependencies
run: pip install -r requirements-dev.txt
- name: Run tests
env:
DEEPGRAM_API_KEY: ${{ secrets.DEEPGRAM_API_KEY }}
run: pytest tests/
- name: Notify on failure
if: failure()
uses: slackapi/[email protected]
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/[email protected]
with:
payload: |
{
"text": "The tests have passed for ${{ github.repository }}."
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}