Skip to content

Change log level

Change log level #428

Workflow file for this run

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
types: [opened, reopened, synchronize]
workflow_call:
workflow_dispatch:
name: ci-build
env:
DOTNET_VERSION: 8.0.x
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: Publish API
run: dotnet publish API/API.csproj -c Release -o ./publish/API
- name: Publish LiveControlGateway
run: dotnet publish LiveControlGateway/LiveControlGateway.csproj -c Release -o ./publish/LiveControlGateway
- name: Publish Cron
run: dotnet publish Cron/Cron.csproj -c Release -o ./publish/Cron
- name: Upload API artifacts
uses: actions/upload-artifact@v4
with:
name: API
path: publish/API/*
retention-days: 1
if-no-files-found: error
- name: Upload LiveControlGateway artifacts
uses: actions/upload-artifact@v4
with:
name: LiveControlGateway
path: publish/LiveControlGateway/*
retention-days: 1
if-no-files-found: error
- name: Upload Cron artifacts
uses: actions/upload-artifact@v4
with:
name: Cron
path: publish/Cron/*
retention-days: 1
if-no-files-found: error
containerize:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
project: [API, LiveControlGateway, Cron]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
${{ matrix.project }}.Dockerfile
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{ matrix.project }}
path: publish/
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Get container image name. sed does two things here:
# - Replaces "aB" with "a-b";
# - Replaces "AAA" with "aaa".
# The end result is:
# - "API" becomes "api"
# - "LiveControlGateway" becomes "live-control-gateway"
- name: Get image name
id: name
run: echo "name=$(echo "${{ matrix.project }}" | sed -r 's|([a-z0-9])([A-Z])|\1-\L\2|g;s|([A-Z])|\L\1|g')" >> $GITHUB_OUTPUT
- name: Find latest tag
uses: oprypin/find-latest-tag@v1
id: latest-tag
with:
repository: ${{ github.repository }}
regex: '^[0-9]+.[0-9]+.[0-9]+$'
releases-only: false
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ steps.name.outputs.name }}
flavor: |
latest=false
tags: |
type=raw,value={{branch}},enable=${{ github.ref_type == 'branch' && github.event_name != 'pull_request' }}
type=raw,value=latest,enable=${{ steps.latest-tag.outputs.tag == github.ref_name }}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.project }}.Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy-production:
runs-on: ubuntu-latest
needs: containerize
if: ${{ github.ref_type == 'branch' && github.event_name != 'pull_request' && github.ref_name == 'master' }}
environment: production
steps:
- name: Call deployment webhook
shell: bash
env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
run: |
curl -X POST -d "" "$WEBHOOK_URL"
deploy-staging:
runs-on: ubuntu-latest
needs: containerize
if: ${{ github.ref_type == 'branch' && github.event_name != 'pull_request' && github.ref_name == 'develop' }}
environment: staging
steps:
- name: Call deployment webhook
shell: bash
env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
run: |
curl -X POST -d "" "$WEBHOOK_URL"