-
Notifications
You must be signed in to change notification settings - Fork 2
210 lines (189 loc) · 8.35 KB
/
l5-swagger-generate.yml
File metadata and controls
210 lines (189 loc) · 8.35 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: OpenAPI generation
on:
push:
pull_request:
jobs:
openapi-generate:
runs-on: ubuntu-latest
env:
OTEL_SERVICE_ENABLED: false
APP_ENV: testing
APP_DEBUG: true
APP_KEY: "base64:4vh0op/S1dAsXKQ2bbdCfWRyCI9r8NNIdPXyZWt9PX4="
DEV_EMAIL_TO: smarcet@gmail.com
APP_URL: http://localhost
DB_CONNECTION: model
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: api_config
DB_USERNAME: root
DB_PASSWORD: 1qaz2wsx
SS_DB_HOST: 127.0.0.1
SS_DB_PORT: 3310
SS_DATABASE: api_model
SS_DB_USERNAME: root
SS_DB_PASSWORD: 1qaz2wsx
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
REDIS_DB: 0
REDIS_PASSWORD: 1qaz2wsx
REDIS_DATABASES: 16
SSL_ENABLED: false
SESSION_DRIVER: redis
PHP_VERSION: "8.3"
CACHE_DRIVER: redis
SESSION_COOKIE_DOMAIN: localhost
SESSION_COOKIE_SECURE: false
QUEUE_DRIVER: redis
REGISTRATION_DEFAULT_PAYMENT_PROVIDER: Stripe
REGISTRATION_DEFAULT_STRIPE_TEST_MODE: true
REGISTRATION_DEFAULT_LIVE_STRIPE_PRIVATE_KEY:
REGISTRATION_DEFAULT_LIVE_STRIPE_PUBLISHABLE_KEY:
REGISTRATION_DEFAULT_LIVE_WEBHOOK_SECRET:
REGISTRATION_DEFAULT_TEST_STRIPE_PRIVATE_KEY: sk_test_12345
REGISTRATION_DEFAULT_TEST_STRIPE_PUBLISHABLE_KEY: pk_12345
REGISTRATION_DEFAULT_TEST_WEBHOOK_SECRET: whsec_12345
BOOKABLE_ROOMS_DEFAULT_PAYMENT_PROVIDER: Stripe
BOOKABLE_ROOMS_DEFAULT_STRIPE_TEST_MODE: true
BOOKABLE_ROOMS_DEFAULT_LIVE_STRIPE_PRIVATE_KEY:
BOOKABLE_ROOMS_DEFAULT_LIVE_STRIPE_PUBLISHABLE_KEY:
BOOKABLE_ROOMS_DEFAULT_LIVE_WEBHOOK_SECRET:
BOOKABLE_ROOMS_DEFAULT_TEST_STRIPE_PRIVATE_KEY: sk_test_12345
BOOKABLE_ROOMS_DEFAULT_TEST_STRIPE_PUBLISHABLE_KEY: pk_12345
BOOKABLE_ROOMS_DEFAULT_TEST_WEBHOOK_SECRET: whsec_12345
REGISTRATION_VALIDATE_TICKET_TYPE_REMOVAL: false
MEMCACHED_SERVER_HOST: 127.0.0.1
MEMCACHED_SERVER_PORT: 11211
services:
mysql_api_model:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: ${{ env.SS_DB_PASSWORD }}
MYSQL_DATABASE: ${{ env.SS_DATABASE }}
ports:
- 3310:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10 --name=mysql_api_model
mysql_api_config:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: ${{ env.DB_PASSWORD }}
MYSQL_DATABASE: ${{ env.DB_DATABASE }}
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10
steps:
- name: Start Memcached (with larger item size)
run: |
docker run -d --name ci-memcached -p 11211:11211 memcached:1.6-alpine \
memcached -m 256 -I 5m -c 4096 -t 2
# wait until ready
for i in {1..20}; do
printf "version\r\nquit\r\n" | nc 127.0.0.1 11211 >/dev/null 2>&1 && break
sleep 0.5
done
- name: Create Redis
uses: supercharge/redis-github-action@1.8.1
with:
redis-port: ${{ env.REDIS_PORT }}
redis-password: ${{ env.REDIS_PASSWORD }}
- name: Check out repository code
uses: actions/checkout@v4
- name: Change MYSQL sql_mode
run: >
docker exec mysql_api_model mysql -u root --password=${{ env.SS_DB_PASSWORD }} -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';"
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: pdo_mysql, mbstring, exif, pcntl, bcmath, sockets, gettext, apcu, redis, igbinary, memcached
- name: Install dependencies
uses: ramsey/composer-install@v3
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.COMPOSER_AUTH_TOKEN }}"} }'
- name: Generate OpenAPI docs
run: php artisan l5-swagger:generate
- name: Build Swagger UI preview
run: |
mkdir -p swagger-ui
cp storage/api-docs/api-docs.json swagger-ui/api-docs.json
cat > swagger-ui/index.html << 'HTMLEOF'
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>OpenStackID API - Swagger UI</title>
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist/swagger-ui.css" />
</head>
<body>
<div id="swagger-ui"></div>
<script src="https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js"></script>
<script>
window.onload = () => {
window.ui = SwaggerUIBundle({
url: 'api-docs.json',
dom_id: '#swagger-ui'
});
};
</script>
</body>
</html>
HTMLEOF
- name: Upload Swagger UI artifact
uses: actions/upload-artifact@v4
with:
name: swagger-ui
path: swagger-ui/
if-no-files-found: error
pages-preview:
name: Publish Swagger UI to GitHub Pages
needs: openapi-generate
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Swagger UI artifact
uses: actions/download-artifact@v4
with:
name: swagger-ui
path: swagger-ui
- name: Build public directory for GitHub Pages
run: |
PR_PATH="openapi/pr-${{ github.event.number }}"
mkdir -p "public/${PR_PATH}"
cp -R swagger-ui/* "public/${PR_PATH}/"
echo "Built GitHub Pages content at public/${PR_PATH}"
- name: Publish to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
keep_files: true
- name: Comment preview URL on PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
const baseUrl = `https://${owner}.github.io/${repo}`;
const previewPath = `/openapi/pr-${prNumber}/`;
const url = `${baseUrl}${previewPath}`;
const body = [
'📘 **OpenAPI / Swagger preview**',
'',
`➡️ ${url}`,
'',
'This page is automatically updated on each push to this PR.'
].join('\n');
await github.rest.issues.createComment({
owner,
repo,
issue_number: prNumber,
body,
});