Repository navigation
65 lines (59 loc) · 1.55 KB
/
Copy pathci.yml
File metadata and controls
65 lines (59 loc) · 1.55 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
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
# Must match EXPOSE in the Dockerfile and the port the process listens on.
APP_PORT: "8080"
HEALTH_PATH: "/health"
jobs:
test:
name: Install, test, build (Node ${{ matrix.node }})
runs-on: ubuntu-latest
strategy:
matrix:
node: [22, 24, 26]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci
- run: npm run lint --if-present
- run: npm test
- run: npm run build --if-present
docker:
name: Docker image builds and answers on APP_PORT
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
load: true
push: false
tags: guide-app:ci
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke test the container
run: |
docker run -d --name app -p 8080:${APP_PORT} guide-app:ci
for _ in $(seq 1 30); do
if curl -fsS "http://localhost:8080${HEALTH_PATH}" > /dev/null; then
echo "Container answered on port ${APP_PORT}"; exit 0
fi
sleep 2
done
docker logs app
exit 1