-
Notifications
You must be signed in to change notification settings - Fork 4
143 lines (129 loc) · 5.19 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Build CI
on:
push:
branches:
- main
- 'feature/**'
paths:
- 'src/**'
- 'db/**'
- '.github/workflows/build.yml'
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- 'src/**'
- 'db/**'
workflow_dispatch:
env:
OCTOPUS_PROJECT_NAME: "Trident Manifest File"
OCTOPUS_FEATURE_BRANCH_CHANNEL: Default
OCTOPUS_RELEASE_CHANNEL: Release
OCTOPUS_SPACE: Default
OCTOPUS_API_KEY: ${{ secrets.OCTOPUSSERVERAPIKEY }}
OCTOPUS_URL: http://bobjwalker.octopus.app
jobs:
build-and-push-application:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['8.0.x']
steps:
- uses: actions/checkout@v1
with:
fetch-depth: '0'
- id: ChannelName
name: Set Channel Name
run: |
$branchName = (((${env:GITHUB_REF} -replace "refs/heads/", "") -replace "feature/", "") -replace "bugfix/", "") -replace " ", ""
Write-Host "The Branch Name is: $branchName"
$channelName = "${env:OCTOPUS_RELEASE_CHANNEL}"
Write-Host "The channel name is now $channelName"
if ($branchName -ne "main")
{
Write-Host "The branch is not the main branch, using the feature branch settings instead."
$channelName = "${env:OCTOPUS_FEATURE_BRANCH_CHANNEL}"
Write-Host "The channel name is now $channelName"
}
Write-Host "Setting the Output Variable OCTOPUS_CHANNEL to $channelName"
Write-Output "OCTOPUS_CHANNEL=$channelName" >> $Env:GITHUB_OUTPUT
shell: pwsh
- 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: update tag
uses: richardsimko/update-tag@v1
with:
tag_name: ${{ steps.determine_version.outputs.semVer }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: create artifacts folder
run: |
mkdir "$GITHUB_WORKSPACE/artifacts"
mkdir "$GITHUB_WORKSPACE/artifacts/web"
- name: build website
working-directory: src/Trident.Web
run: dotnet publish --output "$GITHUB_WORKSPACE/artifacts/web" -c Release --runtime win-x64 --sc false --p:Version=${{ steps.determine_version.outputs.semVer }}
- name: package website
id: "website_package"
uses: OctopusDeploy/create-zip-package-action@v3
with:
package_id: Trident.Web
version: ${{ steps.determine_version.outputs.semVer }}
base_path: "artifacts/web"
files: "**/*"
output_folder: packaged
- name: package database
id: "database_package"
uses: OctopusDeploy/create-zip-package-action@v3
with:
package_id: Trident.Database
version: ${{ steps.determine_version.outputs.semVer }}
base_path: "db"
files: "**/*"
output_folder: packaged
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
- name: install buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest
- name: build and push website container
working-directory: src
run: |
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 -f "./Trident.Web/Dockerfile" --build-arg APP_VERSION=${{ steps.determine_version.outputs.semVer }} --tag bobjwalker99/trident:${{ steps.determine_version.outputs.semVer }} --tag bobjwalker99/trident:latest .
- name: push packages to Octopus
uses: OctopusDeploy/push-package-action@v3
with:
packages: |
packaged/**/*.zip
- name: push build information to Octopus
uses: OctopusDeploy/push-build-information-action@v3
with:
packages: |
Trident.Database
Trident.Web
version: ${{ steps.determine_version.outputs.semVer }}
- name: create release
uses: OctopusDeploy/create-release-action@v3
with:
project: ${{ env.OCTOPUS_PROJECT_NAME }}
channel: ${{ steps.ChannelName.outputs.OCTOPUS_CHANNEL }}
release_number: ${{ steps.determine_version.outputs.semVer }}
package_version: ${{ steps.determine_version.outputs.semVer }}