Skip to content

Bump the all-nuget group with 5 updates #264

Bump the all-nuget group with 5 updates

Bump the all-nuget group with 5 updates #264

Workflow file for this run

name: Build and Push F1 API
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# --- JOB 1: THE FACTORY (Build, Test, and Push immutable + test tags) ---
build-and-push:
runs-on: ubuntu-latest
outputs:
image_name_lower: ${{ steps.image-metadata.outputs.image_name_lower }}
api_sha_tag: ${{ steps.image-metadata.outputs.api_sha_tag }}
web_sha_tag: ${{ steps.image-metadata.outputs.web_sha_tag }}
permissions:
contents: read
packages: write
steps:
- name: Compute image metadata
id: image-metadata
run: |
IMAGE_NAME_LOWER="$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')"
SHA_TAG="sha-${GITHUB_SHA::7}"
echo "IMAGE_NAME_LOWER=$IMAGE_NAME_LOWER" >> "$GITHUB_ENV"
echo "SHA_TAG=$SHA_TAG" >> "$GITHUB_ENV"
echo "image_name_lower=$IMAGE_NAME_LOWER" >> "$GITHUB_OUTPUT"
echo "api_sha_tag=${{ env.REGISTRY }}/$IMAGE_NAME_LOWER:$SHA_TAG" >> "$GITHUB_OUTPUT"
echo "web_sha_tag=${{ env.REGISTRY }}/$IMAGE_NAME_LOWER-web:$SHA_TAG" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Run API/Backend Unit Tests with Coverage
run: |
dotnet test tests/F1.Api.Tests/F1.Api.Tests.csproj \
--configuration Release \
--nologo \
--verbosity minimal \
--collect:"XPlat Code Coverage" \
--settings coverlet.api.runsettings \
--results-directory ./coverage/api-coverage
- name: Run Web Unit Tests with Web-Only Coverage
run: |
dotnet test tests/F1.Web.Tests/F1.Web.Tests.csproj \
--configuration Release \
--nologo \
--verbosity minimal \
--collect:"XPlat Code Coverage" \
--settings coverlet.web.runsettings \
--results-directory ./coverage/web-coverage
- name: Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: "**/coverage.cobertura.xml"
badge: true
fail_below_min: true
format: markdown
output: both
thresholds: '10 80'
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push API image
uses: docker/build-push-action@v7
with:
context: .
file: src/F1.Api/Dockerfile
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}:${{ env.SHA_TAG }}
- name: Build and push Web image
uses: docker/build-push-action@v7
with:
context: src/F1.Web
file: src/F1.Web/Dockerfile
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}-web:${{ env.SHA_TAG }}
build-args: |
COMMIT_HASH=${{ github.sha }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
with:
install: true
- name: Promote SHA images to :test tags
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
run: |
# Promote API image SHA tag to :test
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}:test \
${{ steps.image-metadata.outputs.api_sha_tag }}
# Promote Web image SHA tag to :test
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}-web:test \
${{ steps.image-metadata.outputs.web_sha_tag }}
run-e2e-test:
needs: build-and-push
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
environment: test
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Setup Chrome for Testing
id: setup-chrome
uses: browser-actions/setup-chrome@v2
- name: Resolve Chrome binary and print versions
run: |
set -e
CHROME_BIN_PATH=""
if command -v chrome >/dev/null 2>&1; then
CHROME_BIN_PATH="$(command -v chrome)"
elif command -v google-chrome >/dev/null 2>&1; then
CHROME_BIN_PATH="$(command -v google-chrome)"
elif command -v google-chrome-stable >/dev/null 2>&1; then
CHROME_BIN_PATH="$(command -v google-chrome-stable)"
fi
if [ -z "$CHROME_BIN_PATH" ]; then
echo "Chrome binary not found in PATH"
exit 1
fi
echo "CHROME_BIN=$CHROME_BIN_PATH" >> "$GITHUB_ENV"
echo "Using CHROME_BIN=$CHROME_BIN_PATH"
"$CHROME_BIN_PATH" --version || true
chromedriver --version || true
- name: Run Selenium E2E suite against test
env:
E2E_REQUIRED: "false"
E2E_BASE_URL: ${{ secrets.E2E_BASE_URL }}
E2E_API_BASE_URL: ${{ secrets.E2E_API_BASE_URL }}
E2E_CF_CLIENT_ID: ${{ secrets.E2E_CF_CLIENT_ID }}
E2E_CF_CLIENT_SECRET: ${{ secrets.E2E_CF_CLIENT_SECRET }}
E2E_HEADLESS: "true"
E2E_TIMEOUT_SECONDS: "30"
CHROME_BIN: ${{ env.CHROME_BIN }}
CHROMEDRIVER_LOG: ./TestResults/e2e/chromedriver.log
run: |
dotnet test tests/F1.E2E.Tests/F1.E2E.Tests.csproj \
--configuration Release \
--nologo \
--verbosity minimal \
--logger "trx;LogFileName=e2e.trx" \
--results-directory ./TestResults/e2e
- name: Upload E2E test artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: e2e-results
path: |
TestResults/e2e/**
**/chromedriver.log
# --- JOB 2: THE GATEKEEPER (Promote tested image to :stable) ---
deploy-prod:
needs:
- build-and-push
- run-e2e-test
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
environment: production # Requires your manual approval click
permissions:
packages: write
steps:
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Promote API image to stable
run: |
docker buildx imagetools create \
--tag ${{ env.REGISTRY }}/${{ needs.build-and-push.outputs.image_name_lower }}:stable \
${{ needs.build-and-push.outputs.api_sha_tag }}
- name: Promote Web image to stable
run: |
docker buildx imagetools create \
--tag ${{ env.REGISTRY }}/${{ needs.build-and-push.outputs.image_name_lower }}-web:stable \
${{ needs.build-and-push.outputs.web_sha_tag }}