-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yaml
86 lines (86 loc) · 3.16 KB
/
action.yaml
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
name: 'Build'
description: 'Builds c# project and generates artifacts'
inputs:
version:
description: 'The version generated in the prepare step'
required: true
project-path: # id of input
description: 'Path to the deployable project root.'
required: true
project-file: # id of input
description: 'Name of the csproj file.'
required: true
transform-configuration:
description: 'Transform app configurations based on build configuration'
required: true
default: true
setup-environment:
description: 'Setup dotnet build environment'
required: false
default: 'true'
target:
description: 'The dotnet target/runtime environment.'
required: false
default: 'linux-x64'
artifact-name:
description: 'Name for the built artifact to be uploaded as.'
required: false
default: 'publish'
runs:
using: "composite"
steps:
- uses: actions/download-artifact@master
if: ${{ inputs.setup-environment == 'true' }}
with:
name: workspace
path: .
- uses: actions/setup-dotnet@v3
if: ${{ inputs.setup-environment == 'true' }}
with:
dotnet-version: |
6.x
8.x
- name: Set env to Debug
if: (endsWith(github.ref, '/development') && endsWith(github.ref, '/main')) != true
run: |
echo "ENVIRONMENT=Debug" >> $GITHUB_ENV
shell: bash
- name: Set env to staging
if: endsWith(github.ref, '/development')
run: |
echo "ENVIRONMENT=Staging" >> $GITHUB_ENV
shell: bash
- name: Set env to production
if: endsWith(github.ref, '/main')
run: |
echo "ENVIRONMENT=Release" >> $GITHUB_ENV
shell: bash
- name: Transform Install
if: ${{ inputs.transform-configuration == 'true' && inputs.setup-environment == 'true' }}
run: |
dotnet tool install --global dotnet-xdt
shell: bash
- name: Transform Configuration
if: ${{ inputs.transform-configuration == 'true' }}
run: |
dotnet xdt --source ./${{ inputs.project-path }}/App.config --transform ./${{ inputs.project-path }}/App.${{ env.ENVIRONMENT }}.config --output ./${{ inputs.project-path }}/App.config
shell: bash
- name: Build
run: |
dotnet build -p:Version=${{ inputs.version }} --self-contained --runtime ${{inputs.target}} --configuration ${{ env.ENVIRONMENT }} ${{ inputs.project-path }}/${{ inputs.project-file }}
shell: bash
- name: Generate Artifact
if: endsWith(github.ref, '/development') || endsWith(github.ref, '/main')
run: |
dotnet publish --no-build --no-restore --self-contained --runtime ${{inputs.target}} --configuration ${{ env.ENVIRONMENT }} ${{ inputs.project-path }}/${{ inputs.project-file }}
shell: bash
- uses: actions/upload-artifact@master
if: endsWith(github.ref, '/development') || endsWith(github.ref, '/main')
with:
name: ${{ inputs.artifact-name }}
path: |
${{ inputs.project-path }}/bin/${{ env.ENVIRONMENT }}/
${{ inputs.project-path }}/Kubernetes
${{ inputs.project-path }}/Dockerfile
${{ inputs.project-path }}/app.yaml
retention-days: 1