Skip to content

Commit afdf99b

Browse files
Merge pull request #17 from StuartFerguson/task/#14_workflows
Update and rename main.yml to createrelease.yml
2 parents 84d3ecd + b75cc41 commit afdf99b

1 file changed

Lines changed: 114 additions & 0 deletions

File tree

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
name: "Release"
10+
env:
11+
ASPNETCORE_ENVIRONMENT: "Production"
12+
13+
runs-on: ubuntu-16.04
14+
15+
steps:
16+
- uses: actions/checkout@v1
17+
18+
- name: Get the version
19+
id: get_version
20+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
21+
22+
- name: Setup .NET Core 3.0
23+
uses: actions/setup-dotnet@v1
24+
with:
25+
dotnet-version: 3.0.100
26+
27+
- name: Restore Nuget Packages
28+
run: dotnet restore SecurityService.sln --source https://api.nuget.org/v3/index.json --source https://www.myget.org/F/transactionprocessing/api/v3/index.json
29+
30+
- name: Build Code
31+
run: dotnet build SecurityService.sln --configuration Release
32+
33+
- name: Run Unit Tests
34+
run: |
35+
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
36+
dotnet test "SecurityService.UnitTests\SecurityService.UnitTests.csproj"
37+
38+
- name: Build Docker Images
39+
run: |
40+
docker build . --file SecurityService/Dockerfile --tag securityservice:latest --tag stuartferguson/securityservice:latest --tag stuartferguson/securityservice:${{ steps.get_version.outputs.VERSION }}
41+
42+
- name: Publish Images to Docker Hub
43+
run: |
44+
docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }}
45+
docker push stuartferguson/securityservice:latest
46+
docker push stuartferguson/securityservice:${{ steps.get_version.outputs.VERSION }}
47+
48+
- name: Publish API
49+
run: dotnet publish "SecurityService\SecurityService.csproj" --configuration Release --output publishOutput
50+
51+
- name: Setup .NET Core 2.0
52+
uses: actions/setup-dotnet@v1
53+
with:
54+
dotnet-version: 2.0.0
55+
56+
- name: Extract Octopus Tools
57+
run: |
58+
mkdir /opt/octo
59+
cd /opt/octo
60+
wget -O /opt/octo/octopus.zip https://download.octopusdeploy.com/octopus-tools/6.12.0/OctopusTools.6.12.0.portable.zip
61+
unzip /opt/octo/octopus.zip
62+
chmod +x /opt/octo/Octo
63+
64+
- name: Pack Files for Octopus
65+
run: >-
66+
/opt/octo/Octo pack
67+
--outFolder /home/runner/work/SecurityService/SecurityService
68+
--basePath /home/runner/work/SecurityService/SecurityService/publishOutput
69+
--id EstateManagement
70+
--version ${{ steps.get_version.outputs.VERSION }}
71+
--format zip
72+
--verbose
73+
--logLevel=verbose
74+
75+
- name: Push Package to Octopus
76+
run: >-
77+
/opt/octo/Octo push
78+
--server http://sferguson.ddns.net:9001
79+
--apiKey API-UTN58QCF8HSATACNUBY41XPUC
80+
--package /home/runner/work/SecurityService/SecurityService/SecurityService.${{ steps.get_version.outputs.VERSION }}.zip
81+
--overwrite-mode IgnoreIfExists
82+
83+
- name: Get Release
84+
id: getrelease
85+
uses: octokit/request-action@v1.x
86+
with:
87+
route: GET /repos/StuartFerguson/SecurityService/releases/tags/${{ steps.get_version.outputs.VERSION }}
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Build Release Notes
92+
id: buildreleasenotes
93+
uses: gr2m/get-json-paths-action@v1.x
94+
with:
95+
json: ${{ steps.getrelease.outputs.data }}
96+
releasenote: "body"
97+
98+
- name: Create & Deploy Release in Octopus
99+
run: >-
100+
/opt/octo/Octo create-release
101+
--server http://sferguson.ddns.net:9001
102+
--apiKey API-UTN58QCF8HSATACNUBY41XPUC
103+
--project "Security Service"
104+
--version ${{ steps.get_version.outputs.VERSION }}
105+
--channel Default
106+
--deployTo Development
107+
--waitfordeployment
108+
--deploymenttimeout 00:05:00
109+
--releasenotes "${{ steps.buildreleasenotes.outputs.releasenote }}"
110+
111+
- name: Setup .NET Core 3.0
112+
uses: actions/setup-dotnet@v1
113+
with:
114+
dotnet-version: 3.0.100

0 commit comments

Comments
 (0)