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 | |
| permissions: | |
| contents: read | |
| 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] | |
| steps: | |
| - name: Git Checkout | |
| uses: actions/checkout@v5 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| package-manager-cache: false | |
| - 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: Validate dependency resolution | |
| run: npm ls brace-expansion postcss --all | |
| - name: Run Tests | |
| run: npm run-script test-ci | |
| - name: Run client-core tests | |
| run: npm run-script test:core | |
| - name: Send Coverage | |
| run: npm run-script coverage | |
| npm12-build: | |
| name: Validate npm 12 install and build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Git Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| persist-credentials: false | |
| - name: Use Node.js 24 | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 24 | |
| package-manager-cache: false | |
| - name: Use npm 12 | |
| run: npm install --global npm@12 | |
| - name: Install dependencies and build production bundle | |
| run: npm ci | |
| - name: Test dependency compatibility | |
| run: npm run test:dependencies | |
| docker-build-pr: | |
| name: Validate Docker image | |
| needs: test | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Git Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build Docker image without publishing | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| push: false | |
| platforms: linux/amd64 | |
| tags: nightscout/cgm-remote-monitor:pr-${{ github.event.pull_request.number }} | |
| 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@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_USER }} | |
| password: ${{ secrets.DOCKER_PASS }} | |
| - name: Clean git Checkout | |
| if: success() | |
| uses: actions/checkout@v5 | |
| - 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@v7 | |
| 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@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_USER }} | |
| password: ${{ secrets.DOCKER_PASS }} | |
| - name: Clean git Checkout | |
| uses: actions/checkout@v5 | |
| - 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 }} |