Deploy-Main-Single #207
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow to help you get started with Actions | |
name: Deploy-Main-Single | |
################################################################### | |
# Triggers - Controls when the action will run. | |
################################################################### | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
#push: | |
# branches: [ master ] | |
#pull_request: | |
# branches: [ master ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
################################################################### | |
# Environment Variables | |
################################################################### | |
env: | |
# Path to the solution file relative to the root of the project. | |
buildConfiguration: 'Release' | |
buildPlatform: 'Any CPU' | |
dotnet_version: '6.x.x' | |
jobs: | |
Build_Application: | |
runs-on: ubuntu-latest | |
name: 'Build Application' | |
permissions: | |
contents: read | |
# packages: write | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
########################################### | |
# Build App | |
########################################### | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: ${{ env.dotnet_version }} | |
# Generate Build Assembly Version based on Date/Time | |
- name: Generate Version for Build Assembly | |
uses: Azure/powershell@v1 | |
id: setBuildNumber | |
env: | |
POWERSHELL_TELEMETRY_OPTOUT: 1 | |
with: | |
inlineScript: ./GenerateVersionNumber.ps1 | |
# Azure PS version to be used to execute the script, example: 1.8.0, 2.8.0, 3.4.0. To use the latest version, specify "latest". | |
azPSVersion: '3.4.0' | |
# Select the value of the ErrorActionPreference variable for executing the script. Options: stop, continue, silentlyContinue. Default is Stop. | |
errorActionPreference: continue | |
# - name: .NET Build | |
# run: dotnet build MercuryHealth.Web/MercuryHealth.Web.csproj --configuration Release --no-restore | |
# - name: .NET Publish | |
# run: dotnet publish MercuryHealth.Web/MercuryHealth.Web.csproj --configuration Release --no-build --no-restore --output ./publish | |
# Run dotnet build and publish | |
- name: Build Application | |
run: | | |
dotnet restore | |
dotnet build MercuryHealth.Web/MercuryHealth.Web.csproj --configuration ${{ env.buildConfiguration }} --no-restore | |
dotnet publish MercuryHealth.Web/MercuryHealth.Web.csproj --configuration ${{ env.buildConfiguration }} -o './web' /p:FileVersion="${{ steps.setBuildNumber.outputs.BuildNumber }}" /p:Version="${{ steps.setBuildNumber.outputs.BuildNumber }}" /p:AssemblyVersion="${{ steps.setBuildNumber.outputs.BuildNumber }}" | |
#dotnet build MercuryHealth.API/MercuryHealth.API.csproj --configuration ${{ env.buildConfiguration }} --no-restore | |
#dotnet publish MercuryHealth.API/MercuryHealth.API.csproj --configuration ${{ env.buildConfiguration }} -o './api' /p:FileVersion="${{ steps.setBuildNumber.outputs.BuildNumber }}" /p:Version="${{ steps.setBuildNumber.outputs.BuildNumber }}" /p:AssemblyVersion="${{ steps.setBuildNumber.outputs.BuildNumber }}" | |
dotnet build MercuryHealth.FunctionApp/MercuryHealth.FunctionApp.csproj --configuration ${{ env.buildConfiguration }} --no-restore | |
dotnet publish MercuryHealth.FunctionApp/MercuryHealth.FunctionApp.csproj --configuration ${{ env.buildConfiguration }} -o './functionapp' | |
# dotnet build MercuryHealth.UITests/MercuryHealth.UITests.csproj --configuration ${{ env.buildConfiguration }} --no-restore | |
# dotnet publish MercuryHealth.UITests/MercuryHealth.UITests.csproj --configuration ${{ env.buildConfiguration }} -o './uitests' | |
- name: Build Database | |
run: | | |
dotnet restore MercuryHealth.Database/MercuryHealth.Database.csproj | |
dotnet build MercuryHealth.Database/MercuryHealth.Database.csproj --configuration ${{ env.buildConfiguration }} --no-restore --output './database' | |
# - name: dotnet build database | |
# run: dotnet build MercuryHealth.Database/MercuryHealth.Database.csproj --configuration ${{ env.buildConfiguration }} --no-restore --output './database' | |
########################################### | |
# Run Unit Tests | |
########################################### | |
- name: Run Unit Tests | |
run: dotnet test MercuryHealth.UnitTests/MercuryHealth.UnitTests.csproj | |
# - name: Create Release | |
# id: create_release | |
# uses: actions/create-release@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
# with: | |
# tag_name: ${{ github.ref }} | |
# release_name: Release ${{ github.ref }} | |
# body: | | |
# Changes in this Release | |
# - Updates to the code | |
# draft: false | |
# prerelease: false | |
########################################### | |
# Upload Artifacts | |
########################################### | |
- name: Upload Artifacts for Website | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: MercuryHealth.Website | |
path: ${{ github.workspace }}/web | |
- name: Upload Artifacts for FunctionApp | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: MercuryHealth.FunctionApp | |
path: ${{ github.workspace }}/functionapp | |
- name: Upload Artifacts for Database | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: MercuryHealth.Database | |
path: ${{ github.workspace }}/database | |
# - name: Upload Build Artifacts-UI Tests | |
# if: ${{ github.event_name != 'pull_request' }} | |
# uses: actions/upload-artifact@v2 | |
# with: | |
# name: MercuryHealth.UITests | |
# path: ${{ github.workspace }}/uitests | |
# - name: Upload Build Artifacts-UI Tests runsettings file | |
# if: ${{ github.event_name != 'pull_request' }} | |
# uses: actions/upload-artifact@v2 | |
# with: | |
# name: MercuryHealth.UITests | |
# path: ${{ github.workspace }}/MercuryHealth.UITests/MercuryHealthTests.runsettings | |
# - name: Upload Build Artifacts-UI Tests runsettings Transform PS file | |
# if: ${{ github.event_name != 'pull_request' }} | |
# uses: actions/upload-artifact@v2 | |
# with: | |
# name: MercuryHealth.UITests | |
# path: ${{ github.workspace }}/MercuryHealth.UITests/TransformRunSettings.ps1 | |
- name: Upload Artifacts for Infrastucture Files | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: MercuryHealth.IaC | |
path: ${{ github.workspace }}/MercuryHealth.IaC/*.* | |
- name: Upload Artifact CreateReleaseAnnotation PS | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: MercuryHealth.IaC | |
path: ${{ github.workspace }}/MercuryHealth.Website/*.ps1 | |
- name: Upload Artifacts for Load Test Files | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: MercuryHealth.LoadTests | |
path: ${{ github.workspace }}/MercuryHealth.LoadTests/*.* | |
########################################### | |
# Deploy to Environments | |
########################################### | |
dev: | |
#if: contains(github.event_name, 'push') | |
needs: Build_Application | |
uses: ./.github/workflows/deploy-environment-single.yml | |
with: | |
resource-group-base-name: 'rg-MercuryHealth' | |
environment-suffix: 'dev' | |
resource-group-location: 'eastus' | |
approval-required: true | |
secrets: | |
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} | |
cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN}} | |
cloudflare-zone-id: ${{ secrets.CLOUDFLARE_ZONE_ID }} | |
personal-accesstoken: ${{ secrets.PERSONAL_ACCESSTOKEN_GHPages }} | |
github-accesstoken: ${{ secrets.GITHUB_TOKEN }} | |
playwright-serviceaccesstoken: ${{ secrets.PLAYWRIGHT_SERVICE_ACCESS_TOKEN }} | |
playwright-serviceurl: ${{ secrets.PLAYWRIGHT_SERVICE_URL }} | |