-
Notifications
You must be signed in to change notification settings - Fork 23
189 lines (161 loc) · 8.46 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Deploy
# About this workflow:
# It is triggered on push events to branches production and testing. Then it performs a checkout of the current repo
# and sets up a node environment (v12). Following, it will run `npm ci` to build the package. Next, it will look at your
# commit message, if it includes '#patch', '#minor', or '#major' it will bump the package version accordingly.
# Finally, the `npm publish` command will be run, when on branch testing it will run `npm publish --tag beta` to publish
# it under the beta flag on npm. Note: if no '#patch', '#minor', or '#major' flag is present in the latest commit
# AND the package version is not bumped manually the publish step will fail because we can not publish to an existing
# version.
# GitHub repo configuration:
# 1. Go to Manage access and add 'Github Actions' team with role: admin.
# 2. If you have protected branches, go to Branches > edit protected branch > enable 'Restrict who can push to
# matching branches' and add the 'athombv/github-actions' team.
# Note: make sure to commit package-lock.json, this is needed for `npm ci`.
# Defines the trigger for this action, in general you want it to run when pushing to production | testing. For more
# information see: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#about-workflow-events)
on:
workflow_dispatch:
push:
branches:
- production
jobs:
deploy_to_npm:
name: Deploy to NPM
# Only run this job if initiator is not the Homey Github Actions Bot to prevent loops
if: github.actor != 'homey-bot'
runs-on: ubuntu-latest
steps:
# Checks out the current repository.
- name: Checkout git repository
uses: actions/checkout@v2
with:
# The token below is only necessary if you want to push the version bump to a protected branch
token: ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}
# Set git config to reflect Homey Github Actions Bot user
- name: Set up HomeyGithubActionsBot git user
run: |
git config --local user.email "[email protected]"
git config --local user.name "Homey Github Actions Bot"
# Configures a Node.js environment.
- name: Set up node 12 environment
uses: actions/setup-node@v1
with:
node-version: '12'
# Needed for publishing to npm
registry-url: 'https://registry.npmjs.org'
# Run `npm ci && npm run build` to re-create your local environment (make sure to commit your - package-lock.json!).
- name: Build
run: |
npm ci
npm run build
- name: Commit and push webpack build artefact
run: |
git add webpack/index.js || echo "Webpack build artefact did not change"
git commit -m "build: update webpack artefact" || echo "No changes to commit"
git push
- name: Version bump patch
if: "contains(github.event.head_commit.message, '#patch') && !contains(github.event.head_commit.message, '#minor') && !contains(github.event.head_commit.message, '#major')"
run: |
npm version patch
git config pull.rebase false
git pull
git push --follow-tags
- name: Version bump minor
if: "contains(github.event.head_commit.message, '#minor') && !contains(github.event.head_commit.message, '#major')"
run: |
npm version minor
git config pull.rebase false
git pull
git push --follow-tags
- name: Version bump major
if: "contains(github.event.head_commit.message, '#major')"
run: |
npm version major
git config pull.rebase false
git pull
git push --follow-tags
# Publish when this action is running on branch production
- name: Publish
run: |
npm publish
VERSION="$(node -p "require('./package.json').version")"
echo package_version=${VERSION} >> $GITHUB_ENV
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
trigger-repository-dispatch-event:
needs: deploy_to_npm
name: Update dependent repositories
runs-on: ubuntu-latest
steps:
# Note: insert '<org>/<repo>' below (e.g. athombv/create-nodejs), and specify "event_type"
- name: Trigger repository dispatch event athombv/node-homey
run: |
curl -X POST \
https://api.github.com/repos/athombv/node-homey/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Authorization: token ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}' \
-d '{"event_type": "update-homey-lib"}'
- name: Trigger repository dispatch event athombv/homey-mobile-app
run: |
curl -X POST \
https://api.github.com/repos/athombv/homey-mobile-app/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Authorization: token ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}' \
-d '{"event_type": "update-homey-lib"}'
- name: Trigger repository dispatch event athombv/athom-cloud-apps-api
run: |
curl -X POST \
https://api.github.com/repos/athombv/athom-cloud-apps-api/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Authorization: token ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}' \
-d '{"event_type": "update-homey-lib"}'
- name: Trigger repository dispatch event athombv/lambda-apps-onupload
run: |
curl -X POST \
https://api.github.com/repos/athombv/lambda-apps-onupload/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Authorization: token ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}' \
-d '{"event_type": "update-homey-lib"}'
- name: Trigger repository dispatch event athombv/athom-cloud-driver-reference
run: |
curl -X POST \
https://api.github.com/repos/athombv/athom-cloud-driver-reference/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Authorization: token ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}' \
-d '{"event_type": "update-homey-lib"}'
- name: Trigger repository dispatch event athombv/node-homey-core
run: |
curl -X POST \
https://api.github.com/repos/athombv/node-homey-core/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Authorization: token ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}' \
-d '{"event_type": "update-homey-lib"}'
- name: Trigger repository dispatch event athombv/node-homey-pro
run: |
curl -X POST \
https://api.github.com/repos/athombv/node-homey-pro/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Authorization: token ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}' \
-d '{"event_type": "update-homey-lib"}'
- name: Trigger repository dispatch event athombv/homey-client
run: |
curl -X POST \
https://api.github.com/repos/athombv/homey-client/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Authorization: token ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}' \
-d '{"event_type": "update-homey-lib"}'
- name: Trigger repository dispatch event athombv/athom-cloud-my-homey-app
run: |
curl -X POST \
https://api.github.com/repos/athombv/athom-cloud-my-homey-app/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Authorization: token ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}' \
-d '{"event_type": "update-homey-lib"}'
- name: Trigger repository dispatch event athombv/athom-cloud-website
run: |
curl -X POST \
https://api.github.com/repos/athombv/athom-cloud-website/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Authorization: token ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}' \
-d '{"event_type": "update-homey-lib"}'