forked from TracPlus/theseus-action-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
69 lines (69 loc) · 2.62 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
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
target:
description: 'The dotnet target/runtime environment.'
required: false
default: 'linux-x64'
runs:
using: "composite"
steps:
- uses: actions/download-artifact@master
with:
name: workspace
path: .
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.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 Configuration
if: ${{ inputs.transform-configuration == 'true' }}
run: |
dotnet tool install --global dotnet-xdt
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: publish
path: |
${{ inputs.project-path }}/bin/${{ env.ENVIRONMENT }}/net6.0/${{inputs.target}}/publish
${{ inputs.project-path }}/Kubernetes
${{ inputs.project-path }}/Dockerfile
retention-days: 1