-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (100 loc) · 4.55 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
name: RandomQuotes-build-test
on:
push:
branches:
- main
- 'feature/**'
- 'bugfix/**'
workflow_dispatch:
env:
OCTOPUS_PROJECT_NAME: Random Quotes
OCTOPUS_RELEASE_ENVIRONMENT: Development
OCTOPUS_API_KEY: ${{ secrets.OCTOPUSSERVERAPIKEY }}
OCTOPUS_HOST: ${{ secrets.OCTOPUSSERVERURL }}
jobs:
get-release-information:
runs-on: windows-latest
outputs:
OCTOPUS_ENVIRONMENT: ${{ steps.step1.outputs.OctopusEnvironmentName }}
VERSION: ${{ steps.step1.outputs.OctopusVersionNumber }}
steps:
- uses: actions/checkout@v3
- id: step1
name: Get Octopus Information
run: |
$environmentName = "${env:OCTOPUS_RELEASE_ENVIRONMENT}"
Write-Host "The environment name is now $environmentName"
$versionNumber = "1.${env:GITHUB_RUN_NUMBER}"
Write-Host "The version number is now $versionNumber"
Write-Host "Setting the Output Variable VERSION to $versionNumber"
echo "::set-output name=OctopusVersionNumber::$versionNumber"
Write-Host "Setting the Output Variable OCTOPUS_ENVIRONMENT to $environmentName"
echo "::set-output name=OctopusEnvironmentName::$environmentName"
shell: powershell
build-and-push-application:
needs: [get-release-information]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Set up DotNET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: 5.x
- id: determine_version
name: Determine Version
uses: gittools/actions/gitversion/[email protected]
with:
additionalArguments: /overrideconfig mode=Mainline
- name: create artifacts folder
run: |
mkdir "$GITHUB_WORKSPACE/artifacts"
mkdir "$GITHUB_WORKSPACE/artifacts/web"
mkdir "$GITHUB_WORKSPACE/artifacts/database"
- name: install octopus cli
uses: OctopusDeploy/[email protected]
with:
version: latest
- name: restore dependencies for application
working-directory: src
run: dotnet restore
- name: build website
env:
VERSION_NUMBER: ${{ needs.get-release-information.outputs.VERSION }}
working-directory: src/RandomQuotes
run: dotnet publish --output "$GITHUB_WORKSPACE/artifacts/web" -c Release --runtime linux-x64 --sc false --p:Version=$VERSION_NUMBER
- name: package website
env:
VERSION_NUMBER: ${{ needs.get-release-information.outputs.VERSION }}
run: |
octo pack --id="RandomQuotes" --format="Zip" --version="$VERSION_NUMBER" --basePath="$GITHUB_WORKSPACE/artifacts/web" --outFolder="$GITHUB_WORKSPACE/artifacts"
- name: build database
env:
VERSION_NUMBER: ${{ needs.get-release-information.outputs.VERSION }}
working-directory: src/RandomQuotes.DbUp
run: dotnet publish --output "$GITHUB_WORKSPACE/artifacts/database" -c Release --runtime linux-x64 --sc true --p:PublishSingleFile=true --p:PublishTrimmed=true --p:Version=$VERSION_NUMBER
- name: package database
env:
VERSION_NUMBER: ${{ needs.get-release-information.outputs.VERSION }}
run: |
octo pack --id="RandomQuotes.DbUp" --format="Zip" --version="$VERSION_NUMBER" --basePath="$GITHUB_WORKSPACE/artifacts/database" --outFolder="$GITHUB_WORKSPACE/artifacts"
- name: push packages to Octopus
uses: OctopusDeploy/[email protected]
with:
api_key: ${{ env.OCTOPUS_API_KEY }}
server: ${{ env.OCTOPUS_HOST }}
packages: "artifacts/RandomQuotes.DbUp.${{ needs.get-release-information.outputs.VERSION }}.zip,artifacts/RandomQuotes.${{ needs.get-release-information.outputs.VERSION }}.zip"
- name: create and deploy release
uses: OctopusDeploy/[email protected]
with:
api_key: ${{ env.OCTOPUS_API_KEY }}
server: ${{ env.OCTOPUS_HOST }}
project: ${{ env.OCTOPUS_PROJECT_NAME }}
deploy_to: ${{ needs.get-release-information.outputs.OCTOPUS_ENVIRONMENT }}
release_number: ${{ needs.get-release-information.outputs.VERSION }}
package_version: ${{ needs.get-release-information.outputs.VERSION }}