prod-deploy #8
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
name: prod-deploy | |
on: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: windows-latest | |
environment: AZ-Prod | |
steps: | |
- uses: actions/checkout@v4 | |
- name: dependency caching | |
uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- name: configure production front-end environment | |
run: | | |
set-content "rubberduckvba.client\src\environments\environment.prod.ts" -value "export const environment = { production: true, apiBaseUrl: '${{ vars.API_ROOT_URL }}' };" | |
set-content "rubberduckvba.client\src\environments\environment.ts" -value "export const environment = { production: true, apiBaseUrl: '${{ vars.API_ROOT_URL }}' };" | |
- name: dotnet build | |
run: dotnet build rubberduckvba.Server --configuration Release | |
- name: dotnet publish | |
run: dotnet publish "rubberduckvba.Server\rubberduckvba.Server.csproj" --configuration Release --output ${{env.DOTNET_ROOT}}\pub | |
- name: upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pub | |
path: ${{env.DOTNET_ROOT}}\pub | |
deploy: | |
if: github.ref == 'refs/heads/main' | |
runs-on: self-hosted | |
needs: build | |
steps: | |
- name: prepare staging | |
run: remove-item C:/pub/webroot/rubberduckvba.com -Recurse -Force | |
- name: download artifacts | |
uses: actions/[email protected] | |
with: | |
name: pub | |
path: C:/pub/pub-prod.zip | |
- name: staging | |
run: move-item C:/pub/pub-prod.zip C:/pub/webroot/rubberduckvba.com -force | |
- name: deploy iis site | |
run: | | |
stop-webapppool -name "rubberduckvba-prod" | |
stop-webapppool -name "api-prod" | |
stop-iissite -name api-prod -confirm: $false | |
stop-iissite -name rubberduckvba-prod -confirm: $false | |
start-sleep -seconds 10 | |
copy-item C:/pub/webroot/rubberduckvba.com/* C:/inetpub/wwwroot/rubberduckvba.com -Recurse -Force | |
copy-item C:/inetpub/appsettings.prod.json C:/inetpub/wwwroot/rubberduckvba.com/appsettings.json -Force | |
copy-item C:/inetpub/__Web.config C:/inetpub/wwwroot/rubberduckvba.com/wwwroot/browser/Web.config -Force | |
start-webapppool api-prod | |
start-iissite api-prod | |
start-webapppool rubberduckvba-prod | |
start-iissite rubberduckvba-prod | |