Wip/bewest/nightscout telemetry emitter #5934
This file contains hidden or 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: CI test and publish Docker image | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - dev | |
| pull_request: | |
| branches: | |
| - master | |
| - dev | |
| jobs: | |
| test: | |
| name: Run Tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [20, 22, 24] | |
| mongodb-version: [4.4, 5.0, 6.0] | |
| env: | |
| # Temporary: Allow Node 20 until branch protection rules are updated | |
| # See: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/ | |
| ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true | |
| steps: | |
| - name: Git Checkout | |
| uses: actions/checkout@v3 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Start MongoDB ${{ matrix.mongodb-version }} | |
| uses: supercharge/mongodb-github-action@1.3.0 | |
| with: | |
| mongodb-version: ${{ matrix.mongodb-version }} | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Run Tests | |
| run: npm run-script test-ci | |
| - name: Send Coverage | |
| run: npm run-script coverage | |
| docker-build: | |
| name: Build Docker image (${{ matrix.arch }}) | |
| needs: test | |
| if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev') && github.repository_owner == 'nightscout' | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: amd64 | |
| platform: linux/amd64 | |
| runner: ubuntu-latest | |
| - arch: arm64 | |
| platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| env: | |
| DOCKER_IMAGE: nightscout/cgm-remote-monitor | |
| steps: | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USER }} | |
| password: ${{ secrets.DOCKER_PASS }} | |
| - name: Clean git Checkout | |
| if: success() | |
| uses: actions/checkout@v4 | |
| - name: Prepare Docker tags | |
| id: docker-tags | |
| shell: bash | |
| run: | | |
| if [[ "${GITHUB_REF}" == "refs/heads/dev" ]]; then | |
| echo "version_tag=${DOCKER_IMAGE}:dev_${GITHUB_SHA}-${{ matrix.arch }}" >> "$GITHUB_OUTPUT" | |
| echo "latest_tag=${DOCKER_IMAGE}:latest_dev-${{ matrix.arch }}" >> "$GITHUB_OUTPUT" | |
| else | |
| version="$(node -p "require('./package.json').version")" | |
| echo "version_tag=${DOCKER_IMAGE}:${version}-${{ matrix.arch }}" >> "$GITHUB_OUTPUT" | |
| echo "latest_tag=${DOCKER_IMAGE}:latest-${{ matrix.arch }}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build, tag and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| no-cache: true | |
| platforms: ${{ matrix.platform }} | |
| tags: | | |
| ${{ steps.docker-tags.outputs.version_tag }} | |
| ${{ steps.docker-tags.outputs.latest_tag }} | |
| publish: | |
| name: Publish to Docker Hub | |
| needs: docker-build | |
| runs-on: ubuntu-latest | |
| if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev') && github.repository_owner == 'nightscout' | |
| env: | |
| DOCKER_IMAGE: nightscout/cgm-remote-monitor | |
| steps: | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USER }} | |
| password: ${{ secrets.DOCKER_PASS }} | |
| - name: Clean git Checkout | |
| uses: actions/checkout@v4 | |
| - name: Prepare Docker manifest tags | |
| id: docker-tags | |
| shell: bash | |
| run: | | |
| if [[ "${GITHUB_REF}" == "refs/heads/dev" ]]; then | |
| echo "version_tag=${DOCKER_IMAGE}:dev_${GITHUB_SHA}" >> "$GITHUB_OUTPUT" | |
| echo "version_sources=${DOCKER_IMAGE}:dev_${GITHUB_SHA}-amd64 ${DOCKER_IMAGE}:dev_${GITHUB_SHA}-arm64" >> "$GITHUB_OUTPUT" | |
| echo "latest_tag=${DOCKER_IMAGE}:latest_dev" >> "$GITHUB_OUTPUT" | |
| echo "latest_sources=${DOCKER_IMAGE}:latest_dev-amd64 ${DOCKER_IMAGE}:latest_dev-arm64" >> "$GITHUB_OUTPUT" | |
| else | |
| version="$(node -p "require('./package.json').version")" | |
| echo "version_tag=${DOCKER_IMAGE}:${version}" >> "$GITHUB_OUTPUT" | |
| echo "version_sources=${DOCKER_IMAGE}:${version}-amd64 ${DOCKER_IMAGE}:${version}-arm64" >> "$GITHUB_OUTPUT" | |
| echo "latest_tag=${DOCKER_IMAGE}:latest" >> "$GITHUB_OUTPUT" | |
| echo "latest_sources=${DOCKER_IMAGE}:latest-amd64 ${DOCKER_IMAGE}:latest-arm64" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Publish Docker manifests | |
| shell: bash | |
| run: | | |
| docker buildx imagetools create \ | |
| -t "${{ steps.docker-tags.outputs.version_tag }}" \ | |
| ${{ steps.docker-tags.outputs.version_sources }} | |
| docker buildx imagetools create \ | |
| -t "${{ steps.docker-tags.outputs.latest_tag }}" \ | |
| ${{ steps.docker-tags.outputs.latest_sources }} |