2020-07-16 13:16:55 -07:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on: [push, pull_request]
|
|
|
|
|
|
|
|
jobs:
|
2020-07-18 16:53:45 -07:00
|
|
|
ci:
|
2020-07-16 13:16:55 -07:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-node@v2-beta
|
|
|
|
with:
|
|
|
|
node-version: 12
|
2020-08-12 08:36:24 -07:00
|
|
|
registry-url: https://registry.npmjs.org/
|
2020-07-16 13:16:55 -07:00
|
|
|
- name: Get NodeJS Version
|
|
|
|
id: nodeversion
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=version::$(node --version)"
|
|
|
|
- name: Restore node_modules cache
|
|
|
|
id: cache-node-modules
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: node_modules
|
|
|
|
key: ${{ runner.os }}-${{ steps.nodeversion.outputs.version }}-${{ hashFiles('npm-shrinkwrap.json') }}
|
|
|
|
- name: Install dependencies
|
|
|
|
if: steps.cache-node-modules.outputs.cache-hit != 'true'
|
|
|
|
run: npm ci
|
|
|
|
- name: Test
|
|
|
|
run: npm run test-with-coverage
|
|
|
|
- name: Lint
|
2020-08-10 12:06:22 -07:00
|
|
|
run: npm run eslint
|
|
|
|
- name: Docker login
|
2020-08-10 12:54:20 -07:00
|
|
|
if: (github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push'
|
2020-08-10 12:06:22 -07:00
|
|
|
run: echo ${{ secrets.DOCKER_KEY }} | docker login -u koenkk --password-stdin
|
2020-10-09 09:09:40 -07:00
|
|
|
- name: Docker setup - QEMU
|
2020-08-10 12:54:20 -07:00
|
|
|
if: (github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push'
|
2020-10-09 09:09:40 -07:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-10-09 09:12:38 -07:00
|
|
|
with:
|
|
|
|
platforms: all
|
2020-10-09 09:09:40 -07:00
|
|
|
- name: Docker setup - Buildx
|
|
|
|
if: (github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push'
|
|
|
|
id: buildx
|
2020-10-09 09:12:38 -07:00
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
with:
|
|
|
|
version: latest
|
2020-08-10 12:06:22 -07:00
|
|
|
- name: Docker build dev
|
|
|
|
if: github.ref == 'refs/heads/dev' && github.event_name == 'push'
|
|
|
|
run: |
|
2020-10-09 09:15:14 -07:00
|
|
|
docker buildx build \
|
2020-08-10 12:06:22 -07:00
|
|
|
--build-arg COMMIT=$(git rev-parse --short HEAD) \
|
2020-10-09 09:21:50 -07:00
|
|
|
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7 \
|
2020-08-10 12:06:22 -07:00
|
|
|
-f docker/Dockerfile \
|
|
|
|
--push \
|
|
|
|
-t koenkk/zigbee2mqtt:latest-dev \
|
|
|
|
.
|
|
|
|
- name: Docker build release
|
|
|
|
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
|
|
|
|
run: |
|
|
|
|
TAG="$(git describe --tags)"
|
2020-10-09 09:15:14 -07:00
|
|
|
docker buildx build \
|
2020-08-10 12:06:22 -07:00
|
|
|
--build-arg COMMIT=$(git rev-parse --short HEAD) \
|
2020-10-09 09:21:50 -07:00
|
|
|
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7 \
|
2020-08-10 12:06:22 -07:00
|
|
|
-f docker/Dockerfile \
|
|
|
|
--push \
|
|
|
|
-t koenkk/zigbee2mqtt:latest -t "koenkk/zigbee2mqtt:$TAG" \
|
|
|
|
.
|
|
|
|
- name: Publish to npm
|
|
|
|
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
|
|
|
|
run: npm publish
|
|
|
|
env:
|
|
|
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN }}
|
|
|
|
- name: Trigger danielwelch/hassio-zigbee2mqtt build
|
|
|
|
if: github.ref == 'refs/heads/dev' && github.event_name == 'push'
|
|
|
|
run: |
|
|
|
|
curl -s \
|
|
|
|
--request POST \
|
|
|
|
--header "Content-Type: application/json" \
|
|
|
|
--data '{"definition": {"id": 1}}' \
|
|
|
|
-u ${{ secrets.HASSIO_TRIGGER_SECRET }} \
|
2020-10-09 05:25:11 -07:00
|
|
|
"https://dev.azure.com/danielwelch2101/hassio-zigbee2mqtt/_apis/build/builds?api-version=5.1"
|