-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (120 loc) · 3.86 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
144
145
146
147
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
jobs:
build:
name: Build - Spec
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Needed fo GitVersion
- name: Setup - .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Setup - GitVersion
uses: gittools/actions/gitversion/setup@v3.0
with:
versionSpec: 5.12.0
- name: Setup - Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Generate - Version
id: gitversion
uses: gittools/actions/gitversion/execute@v3.0
with:
useConfigFile: true
configFilePath: GitVersion.yml
- name: Replace - Version
run: sed -i 's/0.0.0/${{ steps.gitversion.outputs.majorMinorPatch }}-${{ steps.gitversion.outputs.preReleaseLabel }}${{ steps.gitversion.outputs.preReleaseNumber }}/g' openapi/openapi.yml
- name: Bun - Install
run: bun install --frozen-lockfile
- name: Bun - Lint
run: bun run lint
- name: Bun - Build
run: bun run build
- name: Upload - Spec
uses: actions/upload-artifact@v4
with:
name: spec
path: dist
retention-days: 90
if-no-files-found: error
- name: Release - Upload assets
uses: softprops/action-gh-release@v2
if: ${{ github.event_name == 'release' }}
with:
files: |
dist/*.html
dist/*.yaml
dist/*.yml
dist/*.json
pages:
name: Pages - Update branch
runs-on: ubuntu-latest
needs: build
if: ${{ github.ref_name == github.event.repository.default_branch || github.event_name == 'release' }}
permissions:
contents: write
actions: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Clean - /preview
if: ${{ github.ref_name == github.event.repository.default_branch }}
run: |
rm -rf /preview
- name: Clean - /
if: ${{ github.event_name == 'release' }}
run: |
rm -f ./*.{html,yaml,yml,json}
- name: Download - spec
uses: actions/download-artifact@v4
with:
name: spec
- name: Setup - Update branch Git User
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
# Move all *.yaml, *.yml, *.json, and *.html files to /preview, mkdir if needed
# git add the entire /preview folder
# for every file added, do a git commit of "Update - <file-name>.json"
- name: Commit - /preview
if: ${{ github.ref_name == github.event.repository.default_branch }}
run: |
# Create the /preview directory if it doesn't exist
mkdir -p preview
# Move all specified files to the /preview directory
mv *.yaml *.yml *.json *.html preview/ 2>/dev/null || true
# Add the entire /preview folder to Git
git add preview
# Commit changes if there are any
git diff --quiet && git diff --staged --quiet || git commit -m "Update - /preview"
# git add all *.yaml, *.yml, *.json, and *.html files in the root dir
# for every file added, do a git commit of "Update - <file-name>.json"
- name: Commit - /
if: ${{ github.event_name == 'release' }}
run: |
# Add all specified files in the root directory
git add *.yaml *.yml *.json *.html
# Commit changes if there are any
git diff --quiet && git diff --staged --quiet || git commit -m "Update - /"
- name: Push
run: git push origin gh-pages
- name: Trigger - Deploy
run: gh workflow run deploy-pages.yml --ref gh-pages
env:
GH_TOKEN: ${{ github.token }}