Skip to content

styling and tests #1625

styling and tests

styling and tests #1625

name: Test, Build and Push Development Docker Image
on:
push:
branches:
- "**" # Run on all branches
pull_request:
branches:
- main
paths:
- "src/web/Jordnaer/**"
- "src/shared/Jordnaer.Shared/**"
- "tests/web/Jordnaer.Tests/**"
- "Dockerfile"
- ".github/workflows/container_ci.yml"
env:
TESTS_DIRECTORY: tests/web/Jordnaer.Tests
REGISTRY: ghcr.io
IMAGE_NAME: nielspilgaard/minimoeder-website
jobs:
test:
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: "10.x"
- name: Test
# Dependabot cannot access secrets, so we disable this step for Dependabot
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
run: >
dotnet test "${{ env.TESTS_DIRECTORY }}"
--logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
--filter Category!=SkipInCi
-p:InformationalVersion=0.0.0-dev+${{ github.sha }}
build-and-push:
# Only build and push the image on pushes to main branch, not tags
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=0.0.0-dev+${{ github.sha }}