Repository navigation
158 lines (136 loc) · 6.59 KB
/
Copy pathdeploy.yml
File metadata and controls
158 lines (136 loc) · 6.59 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
name: Deploy AppMintly to GitHub Pages
on:
push:
branches:
- main
paths:
- 'data/**'
- 'app/**'
- 'components/**'
- 'lib/**'
- 'public/**'
- 'next.config.ts'
- 'package.json'
# This workflow's own file is deliberately NOT a trigger: editing CI does
# not change the built site, and listing it would deploy on every workflow
# tweak (that is how 8841390 shipped an unintended production deployment).
- 'package-lock.json'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: 'pages'
cancel-in-progress: false
env:
GOOGLE_SITE_VERIFICATION_TOKEN: ${{ secrets.GOOGLE_SITE_VERIFICATION_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
# npm 11 is required: npm 10.8.x has a lockfile-validation bug
# ("Invalid: lock file's ajv@6.15.0 does not satisfy ajv@8.20.0") that
# rejects an otherwise-valid, npm-generated lockfile on `npm ci`.
- name: Install npm 11
run: npm install -g npm@11
- name: Install Dependencies
run: npm ci
- name: Verify apps.json Format
run: node -e "const catalog = require('./data/apps.json'); if (!Array.isArray(catalog)) throw new Error('apps.json must be an array'); console.log('Validated ' + catalog.length + ' apps in catalog.');"
# The Pages site is a fully static export of the marketplace. API routes
# (server-side publisher tooling) cannot run on static hosting and are
# excluded from this build; the client falls back to /data/apps.json.
- name: Verify publishers.json Format
run: node -e "const publishers = require('./data/publishers.json'); if (!Array.isArray(publishers)) throw new Error('publishers.json must be an array'); for (const p of publishers) { if (!p.slug || !p.name) throw new Error('publisher record missing slug/name'); } console.log('Validated ' + publishers.length + ' publisher identities.');"
- name: Build Static Next.js Export
run: rm -rf app/api && NEXT_OUTPUT=export NEXT_PUBLIC_BASE_PATH=/appmintly-platform npm run build
- name: Ship Static Catalog Data
run: mkdir -p out/data && cp data/apps.json data/publishers.json data/categories.json data/collections.json data/engineering-status.json data/lab-apps.json data/engineering-events.json data/engineering-builds.json out/data/
- name: Upload Pages Artifact
uses: actions/upload-pages-artifact@v3
with:
path: './out'
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# Canonical host: https://appmintly.pages.dev/ — the EXISTING Cloudflare
# Pages Direct Upload project "appmintly". Deployed via Wrangler direct
# upload from this workflow, so a push to main updates both hosts. The
# project is never created, deleted, renamed or recreated here.
# NOTE: Next.js bakes `basePath` into the exported HTML at build time, so
# the root-scope Cloudflare deployment requires its own static export of
# the SAME production build process with the default root path (identical
# to the verified Direct Upload deployment already live). The GitHub Pages
# build above keeps NEXT_PUBLIC_BASE_PATH=/appmintly-platform unchanged.
deploy-cloudflare:
name: Deploy to Cloudflare Pages (appmintly)
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install npm 11
run: npm install -g npm@11
- name: Install Dependencies
run: npm ci
# Fails fast with a clear message if either Actions secret is missing.
# Values are only checked for presence, never printed.
- name: Verify Cloudflare Actions Secrets
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
test -n "$CLOUDFLARE_API_TOKEN" || { echo 'Missing Actions secret: CLOUDFLARE_API_TOKEN'; exit 1; }
test -n "$CLOUDFLARE_ACCOUNT_ID" || { echo 'Missing Actions secret: CLOUDFLARE_ACCOUNT_ID'; exit 1; }
- name: Build Static Next.js Export (root scope)
run: rm -rf app/api && NEXT_OUTPUT=export npm run build
- name: Ship Static Catalog Data
run: mkdir -p out/data && cp data/apps.json data/publishers.json data/categories.json data/collections.json data/engineering-status.json data/lab-apps.json data/engineering-events.json data/engineering-builds.json out/data/
# Direct Upload to the EXISTING project; --branch=main matches its
# production branch, so this publishes to https://appmintly.pages.dev/.
- name: Deploy to existing Cloudflare Pages project
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
set -euo pipefail
test -n "${CLOUDFLARE_API_TOKEN:-}" || { echo 'Missing Actions secret: CLOUDFLARE_API_TOKEN'; exit 1; }
test -n "${CLOUDFLARE_ACCOUNT_ID:-}" || { echo 'Missing Actions secret: CLOUDFLARE_ACCOUNT_ID'; exit 1; }
# Provenance must describe the tree that was actually built, so read it
# from the checkout rather than the ref that triggered the run.
DEPLOYED_SHA=$(git rev-parse HEAD)
# app/api and out/ legitimately differ at this point (the export build
# removes the API route and writes the bundle), so only SOURCE drift is
# disqualifying.
drift=$(git status --porcelain -- . ':(exclude)out' ':(exclude).next' ':(exclude)app/api')
if [ -n "$drift" ]; then
echo '::error::uncommitted source changes present; the upload would not correspond to any commit'
echo "$drift" | head -5
exit 1
fi
echo "Deploying commit $DEPLOYED_SHA (content built from this checkout)"
npx --yes wrangler@4 pages deploy out \
--project-name=appmintly \
--branch=main \
--commit-hash "$DEPLOYED_SHA" \
--commit-message "$DEPLOYED_SHA $(git log -1 --pretty=%s | cut -c1-80)"