Build, publish and deploy project to UmbHost #25
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: Build, publish and deploy project to UmbHost | |
on: | |
workflow_dispatch: | |
env: | |
SolutionName: ${{ secrets.SOLUTION_NAME }} | |
BuildPlatform: Any CPU | |
BuildConfiguration: Release | |
NodeVersion: 18 | |
FrontendDir: ./frontend | |
jobs: | |
build: | |
runs-on: windows-latest | |
environment: LIVE | |
steps: | |
- name: Get current date | |
id: date | |
uses: Kaven-Universe/[email protected] | |
with: | |
format: "YYYY_MM_DD HH_mm_ss_SSS" | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
submodules: 'true' | |
- name: Use Node.js ${{env.NodeVersion}} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{env.NodeVersion}} | |
- uses: actions/cache@v3 | |
id: cache-nuget-h5yr | |
with: | |
path: | | |
~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget-h5yr | |
- name: Install NPM dependencies | |
run: npm ci | |
working-directory: ${{env.FrontendDir}} | |
- name: Build frontend | |
run: npm run build | |
working-directory: ${{env.FrontendDir}} | |
- name: Create Build Directory | |
run: mkdir _build | |
- name: Variable Substitution | |
uses: microsoft/variable-substitution@v1 | |
with: | |
#comma separated list of XML/JSON/YAML files in which tokens are to be substituted. Files names must be specified relative to the folder-path. | |
files: 'appsettings.json' | |
env: | |
ConnectionStrings.umbracoDbDSN: ${{ secrets.UMBHOST_DATABASE_CONNECTION_STRING }} | |
ConnectionStrings.umbracoDbDSN_ProviderName: "Microsoft.Data.SqlClient" | |
Twitter.ConsumerKey: ${{secrets.TWITTER_CONSUMER_KEY}} | |
Twitter.ConsumerSecret: ${{secrets.TWITTER_CONSUMER_SECRET}} | |
Twitter.AccessToken: ${{secrets.TWITTER_ACCESS_TOKEN}} | |
Twitter.AccessTokenSecret: ${{secrets.TWITTER_ACCESS_TOKEN_SECRET}} | |
API.Offline: "false" | |
API.CreateOfflineFile: "false" | |
- name: Build Solution | |
run: | | |
dotnet build ${{env.SolutionName}} /nologo /nr:false /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:DeleteExistingFiles=True /p:SkipInvalidConfigurations=true /p:IncludeSetAclProviderOnDestination=False /p:AutoParameterizationWebConfigConnectionStrings=False /p:platform="${{env.BuildPlatform}}" /p:configuration="${{env.BuildConfiguration}}" /p:PackageLocation="_build" | |
- name: Deploy to UmbHost EU | |
uses: UmbHost/[email protected] | |
with: | |
website-name: ${{ secrets.UMBHOST_WEBSITE_NAME }} | |
server-computer-name: ${{ secrets.UMBHOST_SERVER_COMPUTER_NAME }} | |
server-username: ${{ secrets.UMBHOST_USERNAME }} | |
server-password: ${{ secrets.UMBHOST_PASSWORD }} | |
source-path: '_build' | |
source-fileName: h5yr.zip | |
- name: Tag Build | |
uses: tvdias/[email protected] | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ProductionBuild-${{ steps.date.outputs.year }}${{ steps.date.outputs.month }}${{ steps.date.outputs.day }}-${{ github.run_number }} |