|
1 |
| -name: Publish Python 🐍 distributions |
| 1 | +name: Test and Deploy |
2 | 2 | on:
|
3 | 3 | push:
|
4 |
| - tags: |
5 |
| - - '*' |
| 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' |
6 | 11 | workflow_dispatch:
|
7 | 12 |
|
8 | 13 | jobs:
|
| 14 | + test: |
| 15 | + name: Test |
| 16 | + runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 20 |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + python-version: [ '3.6', '3.7', '3.8', '3.9' ] |
| 21 | + steps: |
| 22 | + - name: Checkout twilio-python |
| 23 | + uses: actions/checkout@v2 |
| 24 | + |
| 25 | + - name: Set up Python |
| 26 | + uses: actions/setup-python@v2 |
| 27 | + with: |
| 28 | + python-version: ${{ matrix.python-version }} |
| 29 | + |
| 30 | + - name: Install Dependencies |
| 31 | + run: | |
| 32 | + pip install virtualenv --upgrade |
| 33 | + make install |
| 34 | + make test-install |
| 35 | +
|
| 36 | + - name: Run the tests |
| 37 | + run: make test |
| 38 | + |
9 | 39 | deploy:
|
10 | 40 | name: Deploy
|
| 41 | + if: success() && github.ref_type == 'tag' |
| 42 | + needs: [ test ] |
11 | 43 | runs-on: ubuntu-latest
|
12 | 44 | steps:
|
13 | 45 | - name: Checkout twilio-python
|
|
19 | 51 | uses: docker/login-action@v1
|
20 | 52 | with:
|
21 | 53 | username: ${{ secrets.DOCKER_USERNAME }}
|
22 |
| - password: ${{ secrets.DOCKER_TOKEN }} |
| 54 | + password: ${{ secrets.DOCKER_AUTH_TOKEN }} |
23 | 55 |
|
24 | 56 | # The expression strips off the shortest match from the front of the string to yield just the tag name as the output
|
25 | 57 | - name: Get tagged version
|
@@ -49,16 +81,16 @@ jobs:
|
49 | 81 |
|
50 | 82 | notify-on-failure:
|
51 | 83 | name: Slack notify on failure
|
52 |
| - if: ${{ failure() }} |
53 |
| - needs: [ deploy ] |
| 84 | + if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag') |
| 85 | + needs: [ test, deploy ] |
54 | 86 | runs-on: ubuntu-latest
|
55 | 87 | steps:
|
56 | 88 | - uses: rtCamp/action-slack-notify@v2
|
57 | 89 | env:
|
58 |
| - SLACK_COLOR: 'danger' |
| 90 | + SLACK_COLOR: failure |
59 | 91 | SLACK_ICON_EMOJI: ':github:'
|
60 |
| - SLACK_MESSAGE: ${{ format('Failed to deploy {1}{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }} |
61 |
| - SLACK_TITLE: Deployment Failure |
| 92 | + SLACK_MESSAGE: ${{ format('Tests *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }} |
| 93 | + SLACK_TITLE: Action Failure - ${{ github.repository }} |
62 | 94 | SLACK_USERNAME: GitHub Actions
|
63 | 95 | SLACK_MSG_AUTHOR: twilio-dx
|
64 | 96 | SLACK_FOOTER: Posted automatically using GitHub Actions
|
|
0 commit comments