Skip to content

Commit d706527

Browse files
committed
fix: add deployment
1 parent aee2e1e commit d706527

File tree

6 files changed

+1313
-6802
lines changed

6 files changed

+1313
-6802
lines changed

.github/workflows/main.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build
2+
on: [push]
3+
4+
env:
5+
CI_BUILD_NUM: ${{ github.run_id }}
6+
CI_BRANCH: ${{ github.ref_name }}
7+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
8+
9+
permissions:
10+
id-token: write
11+
contents: write # semantic-release-dry verifies the write permissions
12+
issues: read # needed by semantic-release
13+
pull-requests: write # needed by semantic-release
14+
15+
jobs:
16+
test:
17+
name: Test
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Use Node.js 20.x
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20.x'
25+
- run: npm install
26+
- run: npm test
27+
# - uses: codecov/codecov-action@v4
28+
# with:
29+
# token: ${{ secrets.CODECOV_TOKEN }}
30+
31+
test-deploy:
32+
name: Test Deploy
33+
runs-on: ubuntu-latest
34+
if: github.ref != 'refs/heads/main'
35+
needs: test
36+
steps:
37+
- uses: actions/checkout@v4
38+
- name: Use Node.js 20.x
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: '20.x'
42+
- run: npm install
43+
- name: extracting last commit message
44+
run: |
45+
echo "CI_LAST_COMMIT_MSG=$(git show -s --format="%s")" >> $GITHUB_ENV
46+
echo CI_LAST_COMMIT_MSG
47+
- name: Branch Deployment
48+
run: npm run deploy:ci
49+
- name: Post-Deployment Integration Test
50+
run: npm run test-postdeploy
51+
- name: Semantic Release (Dry Run)
52+
run: npm run semantic-release-dry
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
56+
release:
57+
name: Release
58+
runs-on: ubuntu-latest
59+
if: github.ref == 'refs/heads/main'
60+
needs: test
61+
steps:
62+
- uses: actions/checkout@v4
63+
- name: Use Node.js 20.x
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version: '20.x'
67+
- run: npm install
68+
- name: extracting last commit message
69+
run: |
70+
echo "CI_LAST_COMMIT_MSG=$(git show -s --format="%s")" >> $GITHUB_ENV
71+
echo CI_LAST_COMMIT_MSG
72+
- name: Semantic Release
73+
run: npm run semantic-release
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2021 Adobe. All rights reserved.
3+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License. You may obtain a copy
5+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under
8+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
* OF ANY KIND, either express or implied. See the License for the specific language
10+
* governing permissions and limitations under the License.
11+
*/
12+
13+
import path from 'path';
14+
import { fileURLToPath } from 'url';
15+
// eslint-disable-next-line import/no-extraneous-dependencies
16+
import { build } from 'esbuild';
17+
18+
// eslint-disable-next-line no-underscore-dangle
19+
const __filename = fileURLToPath(import.meta.url);
20+
// eslint-disable-next-line no-underscore-dangle
21+
const __dirname = path.dirname(__filename);
22+
23+
try {
24+
await build({
25+
bundle: true,
26+
sourcemap: true,
27+
format: 'esm',
28+
target: 'esnext',
29+
external: ['__STATIC_CONTENT_MANIFEST'],
30+
conditions: ['worker', 'browser'],
31+
entryPoints: [path.join(__dirname, 'src', 'index.js')],
32+
outdir: path.join(__dirname, 'dist'),
33+
outExtension: { '.js': '.mjs' },
34+
});
35+
} catch {
36+
process.exitCode = 1;
37+
}

0 commit comments

Comments
 (0)