xunit3 #449
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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 |