1- name : Tests
1+ name : Test and Deploy
22on :
33 push :
44 branches : [ '*' ]
5+ tags : [ '*' ]
56 pull_request :
67 branches : [ main ]
78 schedule :
1011 workflow_dispatch :
1112
1213jobs :
13- tests :
14- name : Run Tests
14+ test :
15+ name : Test
1516 runs-on : ubuntu-latest
1617 timeout-minutes : 20
1718 steps :
@@ -30,18 +31,37 @@ jobs:
3031 run : make test-docker release
3132 - run : bash <(curl -s https://codecov.io/bash)
3233
34+ deploy :
35+ name : Deploy
36+ if : success() && github.ref_type == 'tag'
37+ needs : [ test ]
38+ runs-on : ubuntu-latest
39+ steps :
40+ - name : Checkout sendgrid-csharp
41+ uses : actions/checkout@v2
42+
43+ - name : Setup .NET Core SDK
44+ 45+ with :
46+ dotnet-version : ' 3.1.x'
47+
48+ - name : Publish package to NuGet
49+ run : |
50+ make release
51+ dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
52+
3353 notify-on-failure :
3454 name : Slack notify on failure
35- if : ${{ failure() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}
36- needs : [ tests ]
55+ if : failure() && github.event_name != 'pull_request' && (github. ref == 'refs/heads/main' || github.ref_type == 'tag')
56+ needs : [ test, deploy ]
3757 runs-on : ubuntu-latest
3858 steps :
3959 - uses : rtCamp/action-slack-notify@v2
4060 env :
41- SLACK_COLOR : ' danger '
61+ SLACK_COLOR : failure
4262 SLACK_ICON_EMOJI : ' :github:'
43- SLACK_MESSAGE : ${{ format('Failed running build on {1}{3} {0 }/{1 }/actions/runs/{2 }', github.server_url, github.repository, github.run_id, ':' ) }}
44- SLACK_TITLE : Build Failure
63+ 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) }}
64+ SLACK_TITLE : Action Failure - ${{ github.repository }}
4565 SLACK_USERNAME : GitHub Actions
4666 SLACK_MSG_AUTHOR : twilio-dx
4767 SLACK_FOOTER : Posted automatically using GitHub Actions
0 commit comments