-
Notifications
You must be signed in to change notification settings - Fork 21
94 lines (81 loc) · 2.46 KB
/
Copy pathci.yml
File metadata and controls
94 lines (81 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Runs on pull requests to main when there are changes to the service files in services/
# Lints and Unit tests the services that have changed
name: Service CI
permissions:
contents: read
packages: write
on:
pull_request:
branches: [main]
paths: ["services/**"]
push:
branches: [main]
tags: ["v*"]
paths: ["services/**"]
env:
NODE_VERSION: 22.x
REGISTRY: ghcr.io
jobs:
changes:
runs-on: ubuntu-latest
outputs:
matrix-include: ${{ steps.set-matrix.outputs.filtered }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for changes
uses: dorny/paths-filter@v3
id: filter
with:
filters: .github/filters.yml
- name: Filter service values based on code changes
id: set-matrix
uses: './.github/actions/filter-options'
with:
options: .github/service-values.yml
options-to-select: ${{ steps.filter.outputs.changes }}
lint-and-test:
runs-on: ubuntu-latest
needs: changes
strategy:
matrix:
include: ${{ fromJSON(needs.changes.outputs.matrix-include) }}
defaults:
run:
working-directory: ${{ matrix.context }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: ${{ matrix.context }}/package-lock.json
- name: Install NPM Dependencies
run: npm ci --quiet
- name: Lint Code
run: npm run checkstyle:ci
- name: Unit Test
run: npm run test-ci
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ matrix.image }}
tags: |
type=sha
type=ref,event=pr
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}