Skip to content

Small refactoring + tests #20

Small refactoring + tests

Small refactoring + tests #20

name: CI/CD authz-app
on:
push:
branches:
- master
workflow_dispatch:
env:
DOTNET_VERSION: '8.x' # Global environment variables
TEST_APP_SERVICE_NAME: 'oed-test-authz-app'
PROD_APP_SERVICE_NAME: 'oed-authz-app'
PROD_RESOURCE_GROUP_NAME: 'altinn-digdir-oed-rg'
PROD_APP_SLOT_NAME: 'production'
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: GitHub metadata
run: |
printf "%s on %s by %s\n" "$GITHUB_REPOSITORY" "$GITHUB_REF_NAME" "$GITHUB_ACTOR"
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build -c Release
- name: Run Tests
run: dotnet test -c Release --no-build --verbosity normal
- name: Publish
run: dotnet publish ./src/oed-authz/oed-authz.csproj --no-build -c Release -o ./publish
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: published-artifacts
path: ./publish/
deploy-to-test:
name: Deploy to Test Environment
needs: build
runs-on: ubuntu-latest
environment:
name: test
steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
name: published-artifacts
path: ./publish/
- name: Deploy to Azure App Service (Test)
uses: azure/webapps-deploy@v2
with:
app-name: '${{ env.TEST_APP_SERVICE_NAME}}'
publish-profile: ${{ secrets.PUBLISH_PROFILE }}
package: ./publish/
deploy-to-prod:
name: Deploy to Production Environment
needs: deploy-to-test
runs-on: ubuntu-latest
environment:
name: production
steps:
- name: Await Manual Approval
if: ${{ github.ref == 'refs/heads/main' }}
run: |
echo "Waiting for manual approval"
echo "::pause::"
- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
name: published-artifacts
path: ./publish/
- name: Deploy to Azure App Service Staging Slot
uses: azure/webapps-deploy@v2
with:
app-name: '${{ env.PROD_APP_SERVICE_NAME }}'
slot-name: ${{ ENV.PROD_APP_SLOT_NAME }}
publish-profile: ${{ secrets.PUBLISH_PROFILE }}
package: ./publish/