-
-
Notifications
You must be signed in to change notification settings - Fork 96
63 lines (51 loc) · 1.43 KB
/
docker-build.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
---
name: Docker build
on:
push:
branches: [ master ]
paths-ignore:
- '**.md'
pull_request:
branches: [ master ]
paths-ignore:
- '**.md'
workflow_dispatch:
workflow_call:
outputs:
test-http-code:
value: ${{ jobs.build-and-test.outputs.test-http-code }}
env:
BASE_TAG: lkurzyniec/netcore-boilerplate
jobs:
build-and-test:
name: docker Build and Test
runs-on: ubuntu-latest
outputs:
test-http-code: ${{ steps.test-container.outputs.HTTP_CODE }}
steps:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build docker image
uses: docker/build-push-action@v6
with:
load: true
tags: ${{ env.BASE_TAG }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test container
id: test-container
run: |
docker run -d --rm -p 5000:8080 ${{ env.BASE_TAG }}:latest
echo "Taking a short nap..."
sleep 5s
echo "Checking health check endpoint..."
curl -Is http://localhost:5000/healthz/ready | head -n 1
HTTP_CODE=$(curl -o /dev/null -s -w "%{http_code}\n" http://localhost:5000/healthz/ready)
echo "HTTP_CODE=$HTTP_CODE" >> $GITHUB_OUTPUT
echo "Validating response..."
if [ "$HTTP_CODE" = "200" ]; then
echo "All is valid!"
else
echo "Response is invalid!"
exit 1
fi