Skip to content

Commit 58d1cd2

Browse files
committed
refactor deploy site workflow
1 parent 07acf6a commit 58d1cd2

File tree

2 files changed

+139
-77
lines changed

2 files changed

+139
-77
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: deploy-pages-workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
project_name:
7+
description: "Cloudflare Pages project name"
8+
required: true
9+
type: string
10+
dist_path:
11+
description: "Path to the built distribution files"
12+
required: true
13+
type: string
14+
deployment_name:
15+
description: "Display name for the deployment step"
16+
required: false
17+
type: string
18+
default: "Deploy to Cloudflare Pages"
19+
node_version:
20+
description: "Node.js version to use"
21+
required: false
22+
type: string
23+
default: "22"
24+
secrets:
25+
CLOUDFLARE_API_TOKEN:
26+
description: "Cloudflare API token"
27+
required: true
28+
CLOUDFLARE_ACCOUNT_ID:
29+
description: "Cloudflare account ID"
30+
required: true
31+
GITHUB_TOKEN:
32+
description: "GitHub token for deployments"
33+
required: false
34+
35+
jobs:
36+
deploy:
37+
name: ${{ inputs.deployment_name }}
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- uses: pnpm/action-setup@v4
43+
44+
- name: Use Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: ${{ inputs.node_version }}
48+
cache: "pnpm"
49+
50+
- name: Install dependencies
51+
run: pnpm i --frozen-lockfile
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
NODE_OPTIONS: "--max_old_space_size=4096"
55+
56+
- name: Bootstrap monorepo
57+
run: pnpm bootstrap
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
NODE_OPTIONS: "--max_old_space_size=4096"
61+
62+
- name: Deploy to Cloudflare Pages
63+
id: deploy
64+
uses: cloudflare/wrangler-action@v3
65+
with:
66+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
67+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
68+
command: pages publish "${{ inputs.dist_path }}" --project-name="${{ inputs.project_name }}"
69+
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- name: Output deployment URL
72+
run: |
73+
echo "Deployment complete!"
74+
echo "Project: ${{ inputs.project_name }}"
75+
echo "Path: ${{ inputs.dist_path }}"

.github/workflows/_deploy-sites.yml

Lines changed: 64 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -65,87 +65,74 @@ on:
6565
type: boolean
6666

6767
jobs:
68-
deploy:
69-
name: Deploy sites
68+
delay:
69+
name: Delay before deployment
7070
runs-on: ubuntu-latest
7171
steps:
72-
- uses: actions/checkout@v4
73-
- uses: pnpm/action-setup@v4
74-
- name: Use Node.js
75-
uses: actions/setup-node@v4
76-
with:
77-
node-version: ${{ inputs.node_version }}
78-
cache: "pnpm"
79-
- run: pnpm i --frozen-lockfile
80-
env:
81-
GITHUB_TOKEN: ${{ github.token }}
82-
NODE_OPTIONS: "--max_old_space_size=4096" # Getting Javascript heap out of memory error. Increasing heap size
83-
- run: pnpm bootstrap
84-
env:
85-
GITHUB_TOKEN: ${{ github.token }}
86-
NODE_OPTIONS: "--max_old_space_size=4096" # Getting Javascript heap out of memory error. Increasing heap size
8772
- run: |
8873
if [ ${{ inputs.delay_seconds }} -gt 0 ]; then
8974
echo "Delaying for ${{ inputs.delay_seconds }} seconds as requested..."
9075
sleep ${{ inputs.delay_seconds }}
76+
else
77+
echo "No delay requested, proceeding immediately..."
9178
fi
92-
# https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/#use-github-actions
93-
# TODO: Make this reusable
94-
- name: Deploy web app
95-
id: deploy-webapp
96-
if: ${{ inputs.deploy_webapp }}
97-
uses: cloudflare/wrangler-action@v3
98-
with:
99-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
100-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
101-
command: pages publish "packages/altair-app/dist/browser" --project-name="altair-webapp"
102-
# Optional: Enable this if you want to have GitHub Deployments triggered
103-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
104-
- name: Deploy docs
105-
id: deploy-docs
106-
if: ${{ inputs.deploy_docs }}
107-
uses: cloudflare/wrangler-action@v3
108-
with:
109-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
110-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
111-
command: pages publish "packages/altair-docs/.vitepress/dist" --project-name="altair-site"
112-
# Optional: Enable this if you want to have GitHub Deployments triggered
113-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
114-
- name: Deploy login-redirect
115-
id: deploy-login-redirect
116-
if: ${{ inputs.deploy_redirect }}
117-
uses: cloudflare/wrangler-action@v3
118-
with:
119-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
120-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
121-
command: pages publish "packages/login-redirect/dist" --project-name="altair-login-redirect"
122-
# Optional: Enable this if you want to have GitHub Deployments triggered
123-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
124-
- name: Deploy sandbox
125-
id: deploy-sandbox
126-
if: ${{ inputs.deploy_sandbox }}
127-
uses: cloudflare/wrangler-action@v3
128-
with:
129-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
130-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
131-
command: pages publish "packages/altair-iframe-sandbox/dist" --project-name="altair-iframe-sandbox"
132-
# Optional: Enable this if you want to have GitHub Deployments triggered
133-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
134-
# - run: |
135-
# export CLOUDFLARE_API_TOKEN="${{ secrets.CLOUDFLARE_API_TOKEN }}"
136-
# export CLOUDFLARE_ACCOUNT_ID="${{ secrets.CLOUDFLARE_ACCOUNT_ID }}"
137-
# cd packages/altair-docs
138-
# npx wrangler@2 pages publish ".vitepress/dist" --project-name="altair-site"
139-
# if: ${{ inputs.deploy_docs }}
140-
# - run: |
141-
# export CLOUDFLARE_API_TOKEN="${{ secrets.CLOUDFLARE_API_TOKEN }}"
142-
# export CLOUDFLARE_ACCOUNT_ID="${{ secrets.CLOUDFLARE_ACCOUNT_ID }}"
143-
# cd packages/login-redirect
144-
# npx wrangler@2 pages publish "dist" --project-name="altair-login-redirect"
145-
# if: ${{ inputs.deploy_redirect }}
146-
# - run: |
147-
# export CLOUDFLARE_API_TOKEN="${{ secrets.CLOUDFLARE_API_TOKEN }}"
148-
# export CLOUDFLARE_ACCOUNT_ID="${{ secrets.CLOUDFLARE_ACCOUNT_ID }}"
149-
# cd packages/altair-iframe-sandbox
150-
# npx wrangler@2 pages publish "dist" --project-name="altair-iframe-sandbox"
151-
# if: ${{ inputs.deploy_sandbox }}
79+
80+
deploy-webapp:
81+
name: Deploy Web App
82+
needs: delay
83+
if: ${{ inputs.deploy_webapp }}
84+
uses: ./.github/workflows/__deploy-pages.yml
85+
with:
86+
project_name: "altair-webapp"
87+
dist_path: "packages/altair-app/dist/browser"
88+
deployment_name: "Deploy Web App"
89+
node_version: ${{ inputs.node_version }}
90+
secrets:
91+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
92+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
95+
deploy-docs:
96+
name: Deploy Docs
97+
needs: delay
98+
if: ${{ inputs.deploy_docs }}
99+
uses: ./.github/workflows/__deploy-pages.yml
100+
with:
101+
project_name: "altair-site"
102+
dist_path: "packages/altair-docs/.vitepress/dist"
103+
deployment_name: "Deploy Documentation"
104+
node_version: ${{ inputs.node_version }}
105+
secrets:
106+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
107+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
110+
deploy-redirect:
111+
name: Deploy Login Redirect
112+
needs: delay
113+
if: ${{ inputs.deploy_redirect }}
114+
uses: ./.github/workflows/__deploy-pages.yml
115+
with:
116+
project_name: "altair-login-redirect"
117+
dist_path: "packages/login-redirect/dist"
118+
deployment_name: "Deploy Login Redirect"
119+
node_version: ${{ inputs.node_version }}
120+
secrets:
121+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
122+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
125+
deploy-sandbox:
126+
name: Deploy Sandbox
127+
needs: delay
128+
if: ${{ inputs.deploy_sandbox }}
129+
uses: ./.github/workflows/__deploy-pages.yml
130+
with:
131+
project_name: "altair-iframe-sandbox"
132+
dist_path: "packages/altair-iframe-sandbox/dist"
133+
deployment_name: "Deploy Iframe Sandbox"
134+
node_version: ${{ inputs.node_version }}
135+
secrets:
136+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
137+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)