2.33.1 #279
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}' |