|
| 1 | +name: Test and Deploy |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ '*' ] |
| 5 | + tags: [ '*' ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + schedule: |
| 9 | + # Run automatically at 8AM PST Monday-Friday |
| 10 | + - cron: '0 15 * * 1-5' |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + name: Test |
| 16 | + runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 20 |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + python-version: [ '2.7', '3.5', '3.6', '3.7', '3.8', '3.9' ] |
| 21 | + steps: |
| 22 | + - name: Checkout sendgrid-python |
| 23 | + uses: actions/checkout@v2 |
| 24 | + |
| 25 | + - name: Build & Test |
| 26 | + run: make test-docker version=${{ matrix.python-version }} |
| 27 | + |
| 28 | + deploy: |
| 29 | + name: Deploy |
| 30 | + if: success() && github.ref_type == 'tag' |
| 31 | + needs: [ test ] |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - name: Checkout sendgrid-python |
| 35 | + uses: actions/checkout@v2 |
| 36 | + |
| 37 | + - name: Set up Python |
| 38 | + uses: actions/setup-python@v2 |
| 39 | + with: |
| 40 | + python-version: '3.6' |
| 41 | + |
| 42 | + - name: Install dependencies |
| 43 | + run: | |
| 44 | + python -m pip install --upgrade pip |
| 45 | + pip install build |
| 46 | + pip install wheel |
| 47 | + python setup.py sdist bdist_wheel |
| 48 | +
|
| 49 | + - name: Publish package to PyPI |
| 50 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 51 | + with: |
| 52 | + user: __token__ |
| 53 | + password: ${{ secrets.PYPI_TOKEN }} |
| 54 | + |
| 55 | + notify-on-failure: |
| 56 | + name: Slack notify on failure |
| 57 | + if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') |
| 58 | + needs: [ test, deploy ] |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: rtCamp/action-slack-notify@v2 |
| 62 | + env: |
| 63 | + SLACK_COLOR: failure |
| 64 | + SLACK_ICON_EMOJI: ':github:' |
| 65 | + SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }} |
| 66 | + SLACK_TITLE: Action Failure - ${{ github.repository }} |
| 67 | + SLACK_USERNAME: GitHub Actions |
| 68 | + SLACK_MSG_AUTHOR: twilio-dx |
| 69 | + SLACK_FOOTER: Posted automatically using GitHub Actions |
| 70 | + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |
| 71 | + MSG_MINIMAL: true |
0 commit comments