-
Notifications
You must be signed in to change notification settings - Fork 5
71 lines (66 loc) · 5.1 KB
/
octopetshopbuild.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
#Note: GitHub Actions does not have a 'demands' command on 'runs-on' yet
#Note: requires secrets OCTOPUSSERVERURL and OCTOPUSSERVERAPIKEY to be configured.
name: OctoPetShopAppBuild
on:
workflow_dispatch:
push:
branches:
- main
env:
solution: '**/*.sln'
buildPlatform: Any CPU
buildConfiguration: Release
jobs:
OctoPetShopBuild:
runs-on: windows-latest
steps:
# We take a copy of the files within the repo and put them in our working directory
- uses: actions/checkout@v2
# We install the latest Octopus Deploy CLI
- uses: OctopusDeploy/install-octopus-cli-action@v1.1.8
# We install the DotNet dependencies we need to help build the application
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: Publish Web
run: dotnet publish ${{ github.workspace }}\OctopusSamples.OctoPetShop.Web/OctopusSamples.OctoPetShop.Web.csproj --configuration ${{ env.BuildConfiguration }} --output ${{ github.workspace }}\output\OctoPetShop.Web\
- name: Publish Product Service API
run: dotnet publish ${{ github.workspace }}\OctopusSamples.OctoPetShop.ProductService/OctopusSamples.OctoPetShop.ProductService.csproj --configuration ${{ env.BuildConfiguration }} --output ${{ github.workspace }}\output\OctoPetShop.ProductService\
- name: Publish database
run: dotnet publish ${{ github.workspace }}\OctopusSamples.OctoPetShop.Database\OctopusSamples.OctoPetShop.Database.csproj --configuration ${{ env.BuildConfiguration }} --output ${{ github.workspace }}\output\OctoPetShop.Database\ --runtime win-x64
- name: Publish Shopping Cart Service
run: dotnet publish ${{ github.workspace }}\OctopusSamples.OctoPetShop.ShoppingCartService\OctopusSamples.OctoPetShop.ShoppingCartService.csproj --configuration ${{ env.BuildConfiguration }} --output ${{ github.workspace }}\output\OctoPetShop.ShoppingCartService\
# We now pack the files created into zip files
- name: Package OctopusSamples.OctoPetShop.Database
run: octo pack --id=OctopusSamples.OctoPetShop.Database --format=Zip --version=${{ github.run_number }} --basePath=${{ github.workspace }}\output\OctoPetShop.Database\ --outFolder=${{ github.workspace }}\output
- name: Package OctopusSamples.OctoPetShop.Web
run: octo pack --id=OctopusSamples.OctoPetShop.Web --format=Zip --version=${{ github.run_number }} --basePath=${{ github.workspace }}\output\OctoPetShop.Web\ --outFolder=${{ github.workspace }}\output
- name: Package OctopusSamples.OctoPetShop.ProductService
run: octo pack --id=OctopusSamples.OctoPetShop.ProductService --format=Zip --version=${{ github.run_number }} --basePath=${{ github.workspace }}\output\OctoPetShop.ProductService\ --outFolder=${{ github.workspace }}\output
- name: Package OctopusSamples.Octopetshop.ShoppingCartService
run: octo pack --id=OctopusSamples.OctoPetShop.ShoppingCartService --format=Zip --version=${{ github.run_number }} --basePath=${{ github.workspace }}\output\OctoPetShop.ShoppingCartService\ --outFolder=${{ github.workspace }}\output
# We then take the files and push them to the Octopus Deploy server
- name: Push OctoPetShop Database
run: octo push --package="${{ github.workspace }}\output\OctopusSamples.OctoPetShop.Database.${{ github.run_number }}.zip" --server="${{ secrets.OCTOPUSSERVERURL }}" --apiKey="${{ secrets.OCTOPUSSERVERAPIKEY }}" --space="${{ secrets.OCTOPUSSERVER_SPACE }}"
- name: Push OctoPetShop Web
run: octo push --package="${{ github.workspace }}\output\OctopusSamples.OctoPetShop.Web.${{ github.run_number }}.zip" --server="${{ secrets.OCTOPUSSERVERURL }}" --apiKey="${{ secrets.OCTOPUSSERVERAPIKEY }}" --space="${{ secrets.OCTOPUSSERVER_SPACE }}"
- name: Push OctoPetShop ProductService
run: octo push --package="${{ github.workspace }}\output\OctopusSamples.OctoPetShop.ProductService.${{ github.run_number }}.zip" --server="${{ secrets.OCTOPUSSERVERURL }}" --apiKey="${{ secrets.OCTOPUSSERVERAPIKEY }}" --space="${{ secrets.OCTOPUSSERVER_SPACE }}"
- name: Push OctoPetShop ShoppingCartService
run: octo push --package="${{ github.workspace }}\output\OctopusSamples.OctoPetShop.ShoppingCartService.${{ github.run_number }}.zip" --server="${{ secrets.OCTOPUSSERVERURL }}" --apiKey="${{ secrets.OCTOPUSSERVERAPIKEY }}" --space="${{ secrets.OCTOPUSSERVER_SPACE }}"
# Create a release
- name: Create a Release in Octopus
uses: OctopusDeploy/create-release-action@v1.1.1
with:
api_key: ${{ secrets.OCTOPUSSERVERAPIKEY }}
project: "OctoPetShop"
server: ${{ secrets.OCTOPUSSERVERURL }}
space: ${{ secrets.OCTOPUSSERVER_SPACE }}
defaultPackageVersion: ${{ github.run_number }}
version: ${{ github.run_number }}
# Deploy to Test
- name: Deploy to Test
run: octo deploy-release --project OctoPetShop --space ${{ secrets.OCTOPUSSERVER_SPACE }} --version latest --deployto Test --server ${{ secrets.OCTOPUSSERVERURL }} --apiKey ${{ secrets.OCTOPUSSERVERAPIKEY }}