Merge pull request #20 from notificationapi-com/update-slack-notifica… #27
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: Python Package | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- "README.md" | |
- "LICENSE" | |
- "CONTRIBUTING.md" | |
jobs: | |
ci: | |
# Using 22.04 to be compatiable with Python 3.7 until it is deprecated | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
python-version: [ 3.7, 3.8, 3.9] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements_dev.txt | |
- name: Lint | |
run: make lint | |
- name: python vulnerability code scan | |
run: make bandit | |
- name: Test & Coverage | |
run: make coverage-ci | |
notify: | |
needs: ci | |
runs-on: ubuntu-latest | |
steps: | |
- name: Send Slack notification on success | |
if: success() | |
uses: 8398a7/action-slack@v3 | |
with: | |
author_name: Python Server SDK | |
status: ${{ needs.ci.result }} | |
fields: repo,message,commit,action,workflow,took | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_SUCCESS_WEBHOOK_URL }} | |
- name: Send Slack notification on failure | |
if: failure() || cancelled() | |
uses: 8398a7/action-slack@v3 | |
with: | |
author_name: Python Server SDK | |
status: ${{ needs.ci.result }} | |
fields: repo,message,commit,action,workflow,took | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_FAILED_WEBHOOK_URL }} | |
cd: | |
needs: ci | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements_dev.txt | |
- name: Release | |
id: release | |
run: make release | |
env: | |
TWINE_USERNAME: "__token__" | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
- name: Send Slack notification for success | |
if: success() | |
uses: 8398a7/action-slack@v3 | |
with: | |
author_name: Python Server SDK | |
status: ${{ job.status }} | |
fields: repo,message,commit,action,workflow,took | |
text: "PyPi Package: https://pypi.org/project/notificationapi-python-server-sdk" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_SUCCESS_WEBHOOK_URL }} | |
- name: Send Slack notification for failure or cancellation | |
if: failure() || cancelled() | |
uses: 8398a7/action-slack@v3 | |
with: | |
author_name: Python Server SDK | |
status: ${{ job.status }} | |
fields: repo,message,commit,action,workflow,took | |
text: "PyPi Package: https://pypi.org/project/notificationapi-python-server-sdk" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_FAILED_WEBHOOK_URL }} | |