Skip to content

Fix build with object matrix #11

Fix build with object matrix

Fix build with object matrix #11

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js CI
on:
push:
branches: ['master']
pull_request:
branches: ['master']
jobs:
test:
if: ${{ ! endsWith(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest
strategy:
matrix:
package:
- archive
- base-node
- common-archive-client
- common-data
- common-postgres
- configurator
- gatherer-http
- gatherer-stdin
- infra-postgres
- infra-redis
- listener
- publisher
target: ['lint', 'test']
node-version: [20]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install
- run: npx nx run-many --target=${{ matrix.target }} --projects=${{ matrix.package }} --output-style=stream
build:
if: ${{ ! endsWith(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest
needs: test
continue-on-error: true
strategy:
matrix:
node-version: [20]
package:
- name: base-node
context: .
image: ghcr.io/unkhz/ruuvipuserrin/base-node
kustomization: ./packages/base-node/.khz-k3s/kustomization.yaml
- name: archive
context: ./packages/archive
image: ghcr.io/unkhz/ruuvipuserrin/archive
kustomization: ./packages/archive/.khz-k3s/kustomization.yaml
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup node 20
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Run npm install
run: npm install
- name: Run node build
run: npx nx run-many --projects=${{ matrix.package }} --target=$node:build --output-style=stream
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: ${{ matrix.package.context }}
push: true
tags: ${{ matrix.package.image }}:latest, ${{ matrix.package.image }}:${{ github.sha }}
- uses: mikefarah/yq@master
with:
cmd: yq --version
- name: Update image version tag
run: |
git config --global user.email "juhani.pelli@gmail.com"
git config --global user.name "Juhani Pelli"
yq e '.images[0].newTag = "${{ github.sha }}"' -i ${{ matrix.package.kustomization }}
git add ${{ matrix.package.kustomization }}
git commit -m "Deploy ${{ github.sha }} [skip ci]"
git push origin ${{ github.event.repository.default_branch }}