Skip to content

Commit

Permalink
ci: Migrate to GitHub Actions (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveSkender authored Jan 7, 2024
1 parent 2c3bb50 commit 048b044
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 118 deletions.
111 changes: 0 additions & 111 deletions .github/build.main.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Build"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build-backend:
name: "Backend"
runs-on: ubuntu-latest

steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.x"
dotnet-quality: "ga"

- name: Build .NET solution
run: >
dotnet build Server/ChartBackend.sln
--configuration Release
--property:ContinuousIntegrationBuild=true
-warnAsError
build-website:
name: "Website"
runs-on: ubuntu-latest

steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: Client/package-lock.json

- name: Install packages
working-directory: ./Client
run: npm install

- name: Build site
working-directory: ./Client
run: npm run build.prod
165 changes: 165 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: Deploy website

on: [ workflow_dispatch ]

concurrency:
group: website-deployer
cancel-in-progress: true

jobs:
build-backend:
runs-on: windows-latest

env:
url: https://charts.stockindicators.dev

steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.x"
dotnet-quality: "ga"

- name: Update configs
shell: pwsh
working-directory: Server/WebApi
run: |
Copy-Item "appsettings.Token.json" -Destination "appsettings.json" -Force
Remove-Item "appsettings.Token.json" -Force
(Get-Content appsettings.json).Replace("__Website__", "${{ env.url }}") | Set-Content appsettings.json
Write-Host "... Done!"
- name: Build .NET solution
run: >
dotnet build Server/ChartBackend.sln
--configuration Release
--property:ContinuousIntegrationBuild=true
-warnAsError
- name: Package Web API
working-directory: Server
run: >
dotnet publish WebApi/WebApi.csproj
--configuration Release
--property:PublishDir="../artifacts/api"
- name: Package Functions
working-directory: Server
run: >
dotnet publish Functions/Functions.csproj
--configuration Release
--property:PublishDir="../artifacts/fns"
- name: Save Web API
uses: actions/upload-artifact@v3
with:
name: api
path: "./Server/artifacts/api"

- name: Save Functions
uses: actions/upload-artifact@v3
with:
name: fns
path: "./Server/artifacts/fns"

build-website:
runs-on: ubuntu-latest

steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: Client/package-lock.json

- name: Install packages
working-directory: Client
run: npm install

- name: Update configs
shell: pwsh
working-directory: Client/src
run: |
(Get-Content index.html).Replace("__GaTag__", "G-17DX6ZW6HP") | Set-Content index.html
Write-Host "... Done!"
- name: Build site
working-directory: Client
run: npm run build.prod

- name: Store artifacts
uses: actions/upload-artifact@v3
with:
name: web
path: Client/dist/app

deploy:
needs: [ "build-backend", "build-website" ]
runs-on: ubuntu-latest

environment:
name: website
url: "https://charts.stockindicators.dev"

steps:

- name: Download Functions package
uses: actions/download-artifact@v3
with:
name: fns
path: artifacts/fns

- name: Show Functions artifacts
working-directory: artifacts/fns
run: ls

- name: Download API package
uses: actions/download-artifact@v3
with:
name: api
path: artifacts/api

- name: Show API artifacts
working-directory: artifacts/api
run: ls

- name: Download Web package
uses: actions/download-artifact@v3
with:
name: web
path: artifacts/web

- name: Show Web artifacts
working-directory: artifacts/web
run: ls

- name: Deploy Functions
uses: Azure/functions-action@v1
with:
app-name: stock-charts-functions
package: artifacts/fns
publish-profile: ${{ secrets.PUBLISH_PROFILE_FNS }}

- name: Deploy API
uses: azure/webapps-deploy@v2
with:
app-name: stock-charts-api
package: artifacts/api
publish-profile: ${{ secrets.PUBLISH_PROFILE_API }}

- name: Deploy website
uses: azure/webapps-deploy@v2
with:
app-name: stock-charts
package: artifacts/web
publish-profile: ${{ secrets.PUBLISH_PROFILE_WEB }}
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Stock Indicators for .NET demo

[![Build status](https://dev.azure.com/skender/Stock.Indicators/_apis/build/status/Stock.Charts)](https://dev.azure.com/skender/Stock.Indicators/_build/latest?definitionId=23)

This is a demo of the [Skender.Stock.Indicators](https://www.nuget.org/packages/Skender.Stock.Indicators) NuGet package. It is an Angular website with a [Chart.js](https://github.com/chartjs/chartjs-chart-financial) financial/candlestick stock chart, with a .NET Web API backend to generate indicators. The indicator library can be implemented in any .NET compatible ecosystem (it does not have to be in an API like this). See the [library documentation](https://dotnet.stockindicators.dev) for more information and a full list of available indicators.

Live demo site: [charts.StockIndicators.dev](https://charts.stockindicators.dev/)
Expand Down
11 changes: 6 additions & 5 deletions Server/Functions/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# About Functions

### ENVIRONMENT VARIABLES for local dev
## ENVIRONMENT VARIABLES for local dev

These can be set as either environment variables or project scoped User Secrets.

```bash
setx AzureWebJobsStorage "UseDevelopmentStorage=true"
setx AlpacaApiKey "YOUR ALPACA API KEY"
setx AlpacaSecret "YOUR ALPACA SECRET KEY"
```

### CRON

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer#cron-expressions
## CRON

<https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer#cron-expressions>

### TIME ZONE
## TIME ZONE

Azure App Service server app settings on the server:
`TZ` : `America/New_York` for Linux instance.
Expand Down

0 comments on commit 048b044

Please sign in to comment.