-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-web.workflow.yml
More file actions
152 lines (146 loc) · 6.71 KB
/
Copy pathdeploy-web.workflow.yml
File metadata and controls
152 lines (146 loc) · 6.71 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
name: Treeseed Web Deploy
on:
workflow_call:
inputs:
environment:
required: true
type: string
action_kind:
required: true
type: string
project_id:
required: false
type: string
preview_id:
required: false
type: string
workflow_dispatch:
inputs:
environment:
required: true
default: staging
type: choice
options:
- staging
- prod
action_kind:
required: true
default: deploy_web
type: choice
options:
- deploy_web
- publish_content
- monitor
project_id:
required: false
type: string
preview_id:
required: false
type: string
jobs:
__WORKING_DIRECTORY_BLOCK__ web:
runs-on: ubuntu-latest
permissions:
contents: read
environment: ${{ inputs.environment == 'prod' && 'production' || 'staging' }}
env:
TREESEED_BOOTSTRAP_MODE: auto
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
TREESEED_CLOUDFLARE_PAGES_PROJECT_NAME: ${{ vars.TREESEED_CLOUDFLARE_PAGES_PROJECT_NAME }}
TREESEED_CLOUDFLARE_PAGES_PREVIEW_PROJECT_NAME: ${{ vars.TREESEED_CLOUDFLARE_PAGES_PREVIEW_PROJECT_NAME }}
TREESEED_CONTENT_BUCKET_NAME: ${{ vars.TREESEED_CONTENT_BUCKET_NAME }}
TREESEED_CONTENT_BUCKET_BINDING: ${{ vars.TREESEED_CONTENT_BUCKET_BINDING }}
TREESEED_FORM_TOKEN_SECRET: ${{ secrets.TREESEED_FORM_TOKEN_SECRET }}
TREESEED_EDITORIAL_PREVIEW_SECRET: ${{ secrets.TREESEED_EDITORIAL_PREVIEW_SECRET }}
TREESEED_PUBLIC_TURNSTILE_SITE_KEY: ${{ vars.TREESEED_PUBLIC_TURNSTILE_SITE_KEY }}
TREESEED_TURNSTILE_SECRET_KEY: ${{ secrets.TREESEED_TURNSTILE_SECRET_KEY }}
TREESEED_SMTP_HOST: ${{ vars.TREESEED_SMTP_HOST }}
TREESEED_SMTP_PORT: ${{ vars.TREESEED_SMTP_PORT }}
TREESEED_SMTP_USERNAME: ${{ vars.TREESEED_SMTP_USERNAME }}
TREESEED_SMTP_PASSWORD: ${{ secrets.TREESEED_SMTP_PASSWORD }}
TREESEED_SMTP_FROM: ${{ vars.TREESEED_SMTP_FROM }}
TREESEED_SMTP_REPLY_TO: ${{ vars.TREESEED_SMTP_REPLY_TO }}
TREESEED_SMTP_SECURE: ${{ vars.TREESEED_SMTP_SECURE }}
TREESEED_PROJECT_DOMAINS: ${{ vars.TREESEED_PROJECT_DOMAINS }}
TREESEED_SITE_URL: ${{ vars.TREESEED_SITE_URL }}
BETTER_AUTH_URL: ${{ vars.BETTER_AUTH_URL || vars.TREESEED_SITE_URL }}
TREESEED_CENTRAL_MARKET_API_BASE_URL: ${{ vars.TREESEED_CENTRAL_MARKET_API_BASE_URL || 'https://api.treeseed.ai' }}
TREESEED_MARKET_API_BASE_URL: ${{ vars.TREESEED_MARKET_API_BASE_URL || vars.TREESEED_CENTRAL_MARKET_API_BASE_URL || 'https://api.treeseed.ai' }}
TREESEED_CATALOG_MARKET_API_BASE_URLS: ${{ vars.TREESEED_CATALOG_MARKET_API_BASE_URLS || vars.TREESEED_MARKET_API_BASE_URL || vars.TREESEED_CENTRAL_MARKET_API_BASE_URL || 'https://api.treeseed.ai' }}
TREESEED_HOSTING_KIND: ${{ vars.TREESEED_HOSTING_KIND }}
TREESEED_HOSTING_REGISTRATION: ${{ vars.TREESEED_HOSTING_REGISTRATION }}
TREESEED_HOSTING_TEAM_ID: ${{ vars.TREESEED_HOSTING_TEAM_ID }}
TREESEED_PROJECT_ID: ${{ inputs.project_id || vars.TREESEED_PROJECT_ID }}
TREESEED_WORKFLOW_ACTION: ${{ inputs.action_kind }}
TREESEED_WORKFLOW_ENVIRONMENT: ${{ inputs.environment }}
TREESEED_WORKFLOW_PROJECT: ${{ inputs.project_id || vars.TREESEED_PROJECT_ID }}
TREESEED_WORKFLOW_PREVIEW_ID: ${{ inputs.preview_id }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: __CACHE_DEPENDENCY_PATH__
- name: Install dependencies
shell: bash
run: |
set -euo pipefail
node <<'NODE'
const fs = require('fs');
const path = require('path');
const packageRoot = 'packages';
if (fs.existsSync(packageRoot)) {
const localPackageNames = new Set();
for (const entry of fs.readdirSync(packageRoot, { withFileTypes: true })) {
if (!entry.isDirectory()) continue;
const file = path.join(packageRoot, entry.name, 'package.json');
if (!fs.existsSync(file)) continue;
const manifest = JSON.parse(fs.readFileSync(file, 'utf8'));
if (typeof manifest.name === 'string') localPackageNames.add(manifest.name);
}
for (const entry of fs.readdirSync(packageRoot, { withFileTypes: true })) {
if (!entry.isDirectory()) continue;
const file = path.join(packageRoot, entry.name, 'package.json');
if (!fs.existsSync(file)) continue;
const manifest = JSON.parse(fs.readFileSync(file, 'utf8'));
let changed = false;
if (manifest.scripts?.prepare) {
delete manifest.scripts.prepare;
changed = true;
}
for (const section of ['dependencies', 'devDependencies', 'optionalDependencies']) {
for (const dependencyName of Object.keys(manifest[section] ?? {})) {
if (dependencyName !== manifest.name && localPackageNames.has(dependencyName)) {
delete manifest[section][dependencyName];
changed = true;
}
}
}
if (changed) fs.writeFileSync(file, `${JSON.stringify(manifest, null, '\t')}\n`);
}
}
NODE
npm ci --ignore-scripts
- name: Build package artifacts
shell: bash
run: |
set -euo pipefail
for dir in packages/sdk packages/ui packages/core packages/cli; do
if test -f "${dir}/package.json"; then npm --prefix "${dir}" run build:dist; fi
done
- name: Run web workflow action
shell: bash
run: |
set -euo pipefail
TIMING_SUMMARY="${RUNNER_TEMP:-/tmp}/treeseed-provider-timing.md"
: > "${TIMING_SUMMARY}"
export TREESEED_PROVIDER_TIMING_SUMMARY_PATH="${TIMING_SUMMARY}"
EXTRA_ARGS=()
if [[ -n "${TREESEED_WORKFLOW_PROJECT:-}" ]]; then EXTRA_ARGS+=(--project-id "${TREESEED_WORKFLOW_PROJECT}"); fi
if [[ -n "${TREESEED_WORKFLOW_PREVIEW_ID:-}" ]]; then EXTRA_ARGS+=(--preview-id "${TREESEED_WORKFLOW_PREVIEW_ID}"); fi
node ./packages/sdk/scripts/run-ts.mjs ./packages/sdk/scripts/tenant-workflow-action.ts --action "${TREESEED_WORKFLOW_ACTION}" --environment "${TREESEED_WORKFLOW_ENVIRONMENT}" "${EXTRA_ARGS[@]}"
if [[ -n "${GITHUB_STEP_SUMMARY:-}" && -s "${TIMING_SUMMARY}" ]]; then cat "${TIMING_SUMMARY}" >> "${GITHUB_STEP_SUMMARY}"; fi