Repository navigation
101 lines (96 loc) · 4.01 KB
/
Copy pathwebsite-deploy.yml
File metadata and controls
101 lines (96 loc) · 4.01 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
name: Publish NMSh website
on:
workflow_dispatch:
inputs:
confirmation:
description: Type nmsh.raisecaterror.com to request production publication
type: string
required: true
permissions:
contents: read
concurrency:
group: nmsh-production
cancel-in-progress: false
jobs:
build:
if: github.repository == 'raiseCatError/notMyShell' && github.ref == 'refs/heads/master' && inputs.confirmation == 'nmsh.raisecaterror.com'
runs-on: ubuntu-24.04
timeout-minutes: 10
defaults:
run:
working-directory: website
outputs:
artifact_id: ${{ steps.site.outputs.artifact-id }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38
with:
node-version: 22.22.0
cache: npm
cache-dependency-path: website/package-lock.json
- run: npm ci
- run: npm test
- run: npm run check
- run: npm run build:launch
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
id: site
with:
name: nmsh-website
path: website/dist
include-hidden-files: true
if-no-files-found: error
retention-days: 1
deploy:
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 10
environment:
name: nmsh-production
defaults:
run:
working-directory: website
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38
with:
node-version: 22.22.0
cache: npm
cache-dependency-path: website/package-lock.json
- run: npm ci --ignore-scripts
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
with:
artifact-ids: ${{ needs.build.outputs.artifact_id }}
path: website/dist
merge-multiple: true
- name: Recheck the published release after approval
run: node scripts/validate-content.mjs --require-published && npm run check:upstream
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Verify manual-only settings and publish the approved artifact
env:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
WRANGLER_SEND_METRICS: 'false'
run: |
node --input-type=module <<'NODE'
const account = process.env.CLOUDFLARE_ACCOUNT_ID;
const token = process.env.CLOUDFLARE_API_TOKEN;
if (!/^[a-f\d]{32}$/.test(account || '') || !token) throw new Error('Production environment credentials are missing.');
const response = await fetch(`https://api.cloudflare.com/client/v4/accounts/${account}/pages/projects/nmsh`, { headers: { Authorization: `Bearer ${token}` } });
const payload = await response.json();
const project = payload.result;
const source = project?.source;
const config = source?.config;
const correctTarget = project?.name === 'nmsh' && project.production_branch === 'master' && project.build_config?.root_dir === 'website' && source?.type === 'github' && config?.owner === 'raiseCatError' && config.repo_name === 'notMyShell';
const manualOnly = config?.production_deployments_enabled === false && config.preview_deployment_setting === 'none' && config.deployments_enabled === false;
if (!response.ok || !payload.success || !correctTarget || !manualOnly) throw new Error('Pages target or manual-only settings changed. Stop and review the project.');
NODE
npx --no-install wrangler pages deploy dist --project-name nmsh --branch master --commit-hash "$GITHUB_SHA"