1- name : Deployment
1+ name : Deploy SDK npm
2+
3+ # If deployment tries to push to npm and then push git tags
4+ # when git tag deployment fails, you cannot push to npm again
5+ # as it doesn't allow overwriting previously deployed artifacts. Deploy
6+ # tag first, then deploy to npm on successful tag deployment.
27on :
3- push :
4- branches : [main, beta, alpha ]
8+ release :
9+ types : [published ]
510
611jobs :
712 deploy :
@@ -17,42 +22,73 @@ jobs:
1722
1823 - name : Compile
1924 run : yarn typescript
20-
21- - name : Deploy via semantic release
22- uses : cycjimmy/semantic-release-action@v3
23- id : semantic-release
24- with :
25- # version numbers below can be in many forms: M, M.m, M.m.p
26- semantic_version : 19
27- extra_plugins : |
28- conventional-changelog-conventionalcommits@4
29- @semantic-release/changelog@6
30- @semantic-release/npm@9
31- @semantic-release/git@10
32- @semantic-release/github@8
33- env :
34- # Needs to push git commits to repo. Needs write access.
35- GITHUB_TOKEN : ${{ secrets.WRITE_ACCESS_BOT_TOKEN }}
36- NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
3725
38- - name : Prepare to sync branches
39- run : |
40- git config --global user.email "21171259+ami-ci@users.noreply.github.com"
41- git config --global user.name "Ami CI"
42- - name : Copy commits into develop after main deployment
43- uses : levibostian/action-sync-branches@v1
26+ - name : Deploy to npm
27+ uses : JS-DevTools/npm-publish@v1
4428 with :
45- behind : develop
46- ahead : main
47- githubToken : ${{ secrets.WRITE_ACCESS_BOT_TOKEN }}
48-
49- - name : Notify team of git tag being created
50- uses : openhousepvt/slack@v1.3.2
51- if : steps.semantic-release.outputs.new_release_published == 'true'
29+ token : ${{ secrets.NPM_TOKEN }}
30+
31+ - name : Notify team of successful deployment
32+ uses : slackapi/slack-github-action@v1.18.0
33+ if : ${{ success() }}
34+ with :
35+ # Use block kit to format the Slack message: https://app.slack.com/block-kit-builder
36+ payload : |
37+ {
38+ "text": "ReactNative SDK deployed to npm",
39+ "blocks": [
40+ {
41+ "type": "section",
42+ "text": {
43+ "type": "mrkdwn",
44+ "text": "*ReactNative* SDK deployed to npm! (deployment step 2 of 2)"
45+ }
46+ },
47+ {
48+ "type": "divider"
49+ },
50+ {
51+ "type": "section",
52+ "text": {
53+ "type": "mrkdwn",
54+ "text": "*Version ${{ github.event.release.tag_name }}*\n\nReactNative SDK deployment progress:\n ~1. <https://github.com/${{github.repository}}/releases/tag/${{ github.event.release.tag_name }}|create git tag>~\n~2. deploy to npm~\n\n"
55+ }
56+ }
57+ ]
58+ }
59+ env :
60+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }}
61+ SLACK_WEBHOOK_TYPE : INCOMING_WEBHOOK
62+
63+ - name : Notify team of failure
64+ uses : slackapi/slack-github-action@v1.18.0
65+ if : ${{ failure() }} # only run this if any previous step failed
5266 with :
53- status : ' success' # in progress status because need to now deploy SDK to maven central for full deployment
54- version : ${{ steps.semantic-release.outputs.new_release_version }}
55- platform : ' ReactNative SDK - deployed'
56- channel : ' #squad-mobile'
67+ # Use block kit to format the Slack message: https://app.slack.com/block-kit-builder
68+ payload : |
69+ {
70+ "text": "ReactNative SDK deployment failure",
71+ "blocks": [
72+ {
73+ "type": "section",
74+ "text": {
75+ "type": "mrkdwn",
76+ "text": "*ReactNative* SDK deployment :warning: failure :warning:"
77+ }
78+ },
79+ {
80+ "type": "divider"
81+ },
82+ {
83+ "type": "section",
84+ "text": {
85+ "type": "mrkdwn",
86+ "text": "ReactNative SDK failed deployment during step *deploy to npm*. View <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|CI server logs> to learn why and fix the issue."
87+ }
88+ }
89+ ]
90+ }
5791 env :
58- SLACK_WEBHOOK_URL : ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }}
92+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_NOTIFY_RELEASES_WEBHOOK_URL }}
93+ SLACK_WEBHOOK_TYPE : INCOMING_WEBHOOK
94+
0 commit comments