forked from oskardudycz/EventSourcing.NodeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (77 loc) · 2.57 KB
/
samples_simple.yml
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
name: Samples - Simple
on:
# run it on push to the default repository branch
push:
branches: [main]
paths:
- "samples/simple/**"
# run it during pull request
pull_request:
paths:
- "samples/simple/**"
defaults:
run:
# relative path to the place where source code (with package.json) is located
working-directory: samples/simple
jobs:
build-and-test-code:
name: Build and test application code
# use system defined below in the tests matrix
runs-on: ${{ matrix.os }}
strategy:
# define the test matrix
matrix:
# selected operation systems to run CI
os: [ubuntu-latest]
# selected node version to run CI
node-version: [20.10.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
# use the node version defined in matrix above
node-version: ${{ matrix.node-version }}
# install dependencies
- run: npm ci
# run linting (ESlint and Prettier)
- run: npm run lint
# run build
- run: npm run build:ts
# run tests
- run: npm test
build-and-push-docker-image:
name: Build Docker image and push to repositories
# run only when code is compiling and tests are passing
needs: build-and-test-code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# setup Docker buld action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image and push to Docker Hub and GitHub Container Registry
uses: docker/build-push-action@v3
with:
# relative path to the place where source code (with package.json) is located
context: ./samples/simple
# Note: tags has to be all lower-case
tags: |
oskardudycz/eventsourcing.nodejs.simple:latest
ghcr.io/oskardudycz/eventsourcing.nodejs/simple:latest
# build on feature branches, push only on main branch
push: ${{ github.ref == 'refs/heads/main' }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}