Skip to content

chore(api): increase rate limit of "content" API due to automated bots #92

chore(api): increase rate limit of "content" API due to automated bots

chore(api): increase rate limit of "content" API due to automated bots #92

name: deployment-api
on:
push:
branches:
- dev
- main
paths:
- '.github/workflows/deployment-api.yml'
- 'src/Squidlr/**'
- 'src/Squidlr.Api/**'
workflow_dispatch:
env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending .NET CLI telemetry to Microsoft.
DOTNET_CLI_TELEMETRY_OPTOUT: true
DEV_STAGE_BRANCH: dev
PROD_STAGE_BRANCH: main
jobs:
build:
runs-on: ubuntu-latest
permissions:
statuses: write
checks: write
contents: write
pull-requests: write
actions: write
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install dependencies
run: dotnet restore src/Squidlr.Api/Squidlr.Api.csproj
- name: Build
run: dotnet build src/Squidlr.Api/Squidlr.Api.csproj --configuration Release --no-restore
- name: Unit Tests
run: dotnet test test/Squidlr.Tests --verbosity normal --logger trx --results-directory "TestResults"
- name: Integration Tests
run: dotnet test test/Squidlr.Api.IntegrationTests --verbosity normal --logger trx --results-directory "TestResults"
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: TestResults
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Create test report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Test report
path: 'TestResults/*.trx'
reporter: dotnet-trx
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Set vars for dev stage
run: |
echo "ENVIRONMENT=staging" >> $GITHUB_ENV
if: ${{ github.ref_name == env.DEV_STAGE_BRANCH }}
- name: Set vars for production stage
run: |
echo "ENVIRONMENT=prod" >> $GITHUB_ENV
if: ${{ github.ref_name == env.PROD_STAGE_BRANCH }}
- name: Checkout
uses: actions/checkout@v4
- name: Set environment variables
uses: ./.github/actions/setvars
with:
varFilePath: ./.github/variables/vars.${{ env.ENVIRONMENT }}.env
- name: Log in to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Build and deploy API container image
uses: azure/container-apps-deploy-action@v1
with:
appSourcePath: ${{ github.workspace }}
dockerfilePath: src/Squidlr.Api/Dockerfile
acrName: ${{ env.ACR_NAME }}
imageToBuild: ${{ env.ACR_LOGIN_SERVER }}/squidlr-api:${{ github.sha }}
containerAppName: ${{ env.CONTAINER_APP_NAME_API }}
resourceGroup: ${{ env.RESOURCE_GROUP_NAME }}
disableTelemetry: true