-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (68 loc) · 2.61 KB
/
build-api.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
name: Build Microservice Demo App (API)
on:
push:
branches:
- main
paths-ignore:
- "NetCoreMicroserviceSample/NetCoreMicroserviceSample.Machine/**"
env:
DOTNET_VERSION: '5.0'
NODE_VERSION: '14.x'
API_PATH: './NetCoreMicroserviceSample/NetCoreMicroserviceSample.Api'
UI_PATH: './NetCoreMicroserviceSample/NetCoreMicroserviceSample.UserInterface'
CONFIG: 'Debug'
jobs:
build:
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@master
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup DotNet 3.1 Environment (for Swashbuckle)
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1'
- name: Setup Node.js ${{ env.NODE_VERSION }} Environment
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 'Install dotnet local tools'
working-directory: ${{ env.API_PATH }}
run: dotnet tool restore
- name: 'Build API (required for generating Swagger file)'
working-directory: ${{ env.API_PATH }}
run: dotnet build --configuration ${{ env.CONFIG }}
- name: 'Generate Swagger file'
working-directory: ${{ env.API_PATH }}
run: dotnet swagger tofile --output obj/api.json bin/${{ env.CONFIG }}/net${{ env.DOTNET_VERSION }}/NetCoreMicroserviceSample.Api.dll v1
- name: 'NPM Install'
working-directory: ${{ env.UI_PATH }}
run: npm install
- name: 'Generate API client with autorest from Swagger file'
working-directory: ${{ env.UI_PATH }}
run: |
npx autorest --input-file=../NetCoreMicroserviceSample.Api/obj/api.json --typescript --output-folder=../NetCoreMicroserviceSample.ApiClient --v3
cd ../NetCoreMicroserviceSample.ApiClient/src
cp -r . ../../../${{ env.UI_PATH }}/src/apiClient
- name: 'Build UI and copy result to API project'
working-directory: ${{ env.UI_PATH }}
run: npm run deploy
- name: Build and push
uses: docker/build-push-action@v2
with:
context: ${{ env.API_PATH }}/..
file: ${{ env.API_PATH }}/Dockerfile
push: true
tags: rstropek/net-core-microservice-sample:latest