-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Build workflow with input parameters. Update readme.
- Loading branch information
Showing
2 changed files
with
152 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# IMPORTANT: | ||
# 1. The Server URL must include the scheme (e.g. https://app.remotely.one). | ||
|
||
# 2. The Server Runtime Identifier determines the target operating system | ||
# for which to build the server. The default "linux-x64" will usually work | ||
# for most Linux-based operating systems. You can see a full list at | ||
# https://docs.microsoft.com/en-us/dotnet/core/rid-catalog. | ||
|
||
# 2. You'll want to keep your fork updated so you can build the latest | ||
# changes. On the GitHub page for your repo, you'll see a message that says, | ||
# "This branch is ## commits behind lucent-sea:master." | ||
# | ||
# Click the "Pull request link next to it." | ||
# | ||
# On the next page click the "switching the base" link. Now it's pulling from | ||
# my repo into yours. Create and complete the pull request to update your repo. | ||
# | ||
# Once your branch has been updated, you can run this workflow again | ||
# to build the latest version. | ||
|
||
name: Build | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
serverUrl: | ||
description: 'Server URL' | ||
required: true | ||
rid: | ||
description: 'Server Runtime Identifier' | ||
required: false | ||
default: "linux-x64" | ||
|
||
jobs: | ||
|
||
build: | ||
|
||
runs-on: windows-latest # For a list of available runner types, refer to | ||
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on | ||
|
||
env: | ||
Solution_Name: Remotely.sln | ||
Configuration: Release | ||
PfxBase64: ${{ secrets.BASE64_ENCODED_PFX }} | ||
PfxKey: ${{ secrets.PFX_KEY }} | ||
SiteUrl: ${{ github.event.inputs.serverUrl }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# Install the .NET Core workload | ||
- name: Install .NET Core | ||
uses: actions/[email protected] | ||
|
||
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild | ||
- name: Setup MSBuild.exe | ||
uses: microsoft/setup-msbuild@v1 | ||
|
||
# Execute all unit tests in the solution | ||
- name: Execute unit tests | ||
run: dotnet test | ||
|
||
# Restore the application to populate the obj folder with RuntimeIdentifiers | ||
- name: Restore the application | ||
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration | ||
|
||
# Decode the base 64 encoded pfx and save the Signing_Certificate | ||
- name: Decode the pfx | ||
run: | | ||
if (!($env:PfxBase64)) { | ||
echo "Skipping cert signing because Base64_Encoded_Pfx secret is missing." | ||
return | ||
} | ||
echo "Creating Pfx for signing assemblies." | ||
$pfx_cert_byte = [System.Convert]::FromBase64String($env:PfxBase64) | ||
$certificatePath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath GitHubActionsWorkflow.pfx | ||
echo "Writing file to $certificatePath." | ||
[IO.File]::WriteAllBytes($certificatePath, $pfx_cert_byte) | ||
# Store the assembly version in an environment variable | ||
- name: Set current version | ||
shell: powershell | ||
run: | | ||
$VersionString = git show -s --format=%ci | ||
$VersionDate = [DateTimeOffset]::Parse($VersionString) | ||
$Year = $VersionDate.Year.ToString() | ||
$Month = $VersionDate.Month.ToString().PadLeft(2, "0") | ||
$Day = $VersionDate.Day.ToString().PadLeft(2, "0") | ||
$Hour = $VersionDate.Hour.ToString().PadLeft(2, "0") | ||
$Minute = $VersionDate.Minute.ToString().PadLeft(2, "0") | ||
$CurrentVersion = "$Year.$Month.$Day.$Hour$Minute" | ||
echo "::set-env name=CurrentVersion::$CurrentVersion" | ||
# This was needed in Azure Pipelines. | ||
#[System.Console]::WriteLine("##vso[task.setvariable variable=CurrentVersion]$CurrentVersion") | ||
Write-Host "Setting current version to $CurrentVersion." | ||
# Run the Publish script to build clients and server. | ||
- name: Run Publish script | ||
shell: powershell | ||
run: | | ||
.\Utilities\Publish.ps1 -CertificatePath "$env:GITHUB_WORKSPACE\GitHubActionsWorkflow.pfx" -CertificatePassword $env:PfxKey -Hostname $env:SiteUrl -CurrentVersion $env:CurrentVersion -RID linux-x64 -OutDir "$env:GITHUB_WORKSPACE\publish" | ||
# Upload build artifact to be deployed from Ubuntu runner | ||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
path: ./publish/ | ||
|
||
|
||
# Remove the pfx | ||
- name: Remove the pfx | ||
run: Remove-Item -path "$env:GITHUB_WORKSPACE\GitHubActionsWorkflow.pfx" | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
env: | ||
SshUsername: ${{ secrets.SSH_USERNAME }} | ||
SshPrivateKey: ${{ secrets.SSH_PRIVATE_KEY }} | ||
SshHostname: ${{ secrets.SSH_HOSTNAME }} | ||
|
||
steps: | ||
|
||
# Install SSH Key | ||
- name: Install SSH Key | ||
uses: shimataro/[email protected] | ||
with: | ||
# SSH private key | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
# public keys of SSH servers | ||
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }} | ||
|
||
# Download Build Artifact | ||
- name: Download build artifact | ||
uses: actions/download-artifact@v2 | ||
|
||
- name: Publish | ||
shell: bash | ||
run: | | ||
rsync -r -v ./artifact/ $SshUsername@$SshHostname:/var/www/remotely/ |
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