-
Notifications
You must be signed in to change notification settings - Fork 1
128 lines (121 loc) · 4.36 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: build
defaults:
run:
working-directory: "Benday.Demo123"
on:
workflow_dispatch:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
AZURE_WEBAPP_NAME: bdcgithubactiondemo # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: 'Benday.Demo123/src/Benday.Demo123.WebUi' # set this to the path to your web app project, defaults to the repository root
PROJECT_TO_PUBLISH_PATH: 'Benday.Demo123/src/Benday.Demo123.WebUi'
PROJECT_TO_PUBLISH_PATH_2: 'Benday.Demo123/src/Benday.Demo123.Api'
DOTNET_VERSION: '8.*' # set this to the dot net version to use
#
# I really want to do this but it doesn't seem to work
# PUBLISH_TO_PATH: '$RUNNER_WORKSPACE/published'
jobs:
build:
runs-on: ubuntu-latest
# runs-on: self-hosted
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
ACCEPT_EULA: Y
SA_PASSWORD: Pa$$word
MSSQL_PID: Standard
ports:
- 1433:1433
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/.npm
key: npm-packages-${{ hashFiles('**/package-lock.json') }}
restore-keys: npm-packages-
- name: print environment vars
run: env
- name: print default working directory
run: pwd
- name: run an ls -l
run: ls -lR
working-directory: '${{ github.workspace }}'
- name: Inspect contexts
run: |
echo ""
echo "The github context is:"
echo "${{ toJson(github) }}"
echo ""
echo "The job context is:"
echo "${{ toJson(job) }}"
echo ""
echo "The steps context is:"
echo "${{ toJson(steps) }}"
echo ""
echo "The runner context is:"
echo "${{ toJson(runner) }}"
echo ""
echo "The strategy context is:"
echo "${{ toJson(strategy) }}"
echo ""
echo "The matrix context is:"
echo "${{ toJson(matrix) }}"
echo ""
#
#
# Here is the workaround for my env variable wish
- name: set environment variable for publishing path for webui project
run: echo "PUBLISH_TO_PATH=$GITHUB_WORKSPACE/webui-published" >> $GITHUB_ENV
- name: set environment variable for publishing path for api project
run: echo "PUBLISH_TO_PATH_2=$GITHUB_WORKSPACE/api-published" >> $GITHUB_ENV
- name: print environment vars again
run: env
# - name: Setup .NET Core
# uses: actions/setup-dotnet@v1
# with:
# dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore dotnet tools
run: dotnet tool restore
- name: Install dependencies for .net core
run: dotnet restore
- name: edit connection string
uses: benday-inc/edit-dbconnstr-in-appsettings@v1.1
with:
pathtosettingsfile: '${{ github.workspace }}/Benday.Demo123/src/Benday.Demo123.WebUi/appsettings.json'
name: "default"
connectionstring: "default conn string 123"
- name: Edit property string value in appsettings.json
uses: benday-inc/set-property-value-in-appsettings@v1.1
with:
pathtosettingsfile: '${{ github.workspace }}/Benday.Demo123/src/Benday.Demo123.WebUi/appsettings.json'
keyname1: 'keylevel1'
keyname2: 'keylevel2'
keyname3: 'keylevel3'
valuetoset: 'asdf asdf'
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Deploy database migrations to container
run: dotnet ef database update
working-directory: '${{ github.workspace }}/Benday.Demo123/src/Benday.Demo123.Api'
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: Publish the web project
run: dotnet publish --configuration Release -o '${{ env.PUBLISH_TO_PATH }}'
working-directory: '${{ env.PROJECT_TO_PUBLISH_PATH }}'
- name: Publish the api project
run: dotnet publish --configuration Release -o '${{ env.PUBLISH_TO_PATH_2 }}'
working-directory: '${{ env.PROJECT_TO_PUBLISH_PATH_2 }}'
- name: publish artifact for web ui
uses: actions/upload-artifact@v2
with:
name: build-output
path: '${{ env.PUBLISH_TO_PATH }}'
- name: publish artifact for api project
uses: actions/upload-artifact@v2
with:
name: build-output-api-project
path: '${{ env.PUBLISH_TO_PATH_2 }}'