-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (72 loc) · 2.13 KB
/
deploy-api.yml
File metadata and controls
85 lines (72 loc) · 2.13 KB
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
# API Deployment Workflow
# Builds and publishes the ASP.NET Core API for deployment
name: Deploy API
permissions:
contents: read
on:
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
default: 'production'
type: choice
options:
- production
- staging
- development
push:
tags:
- 'v*.*.*'
jobs:
build-api:
name: Build and Package API
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 9.0.x
- name: Restore dependencies
run: |
cd TerminplanerApi
dotnet restore
- name: Run tests
run: |
dotnet test TerminplanerApi.Tests/TerminplanerApi.Tests.csproj --configuration Release
- name: Publish API (Linux)
run: |
cd TerminplanerApi
dotnet publish --configuration Release --output ./publish/linux-x64 --runtime linux-x64 --self-contained false
- name: Publish API (Windows)
run: |
cd TerminplanerApi
dotnet publish --configuration Release --output ./publish/win-x64 --runtime win-x64 --self-contained false
- name: Upload Linux artifacts
uses: actions/upload-artifact@v4
with:
name: api-linux-x64
path: TerminplanerApi/publish/linux-x64/
retention-days: 30
- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: api-win-x64
path: TerminplanerApi/publish/win-x64/
retention-days: 30
- name: Create deployment package
run: |
cd TerminplanerApi/publish
tar -czf ../terminplaner-api-linux-x64.tar.gz -C linux-x64 .
cd ../
zip -r terminplaner-api-win-x64.zip publish/win-x64/*
- name: Upload deployment packages
uses: actions/upload-artifact@v4
with:
name: deployment-packages
path: |
TerminplanerApi/terminplaner-api-linux-x64.tar.gz
TerminplanerApi/terminplaner-api-win-x64.zip
retention-days: 90