Skip to content

Commit a46e6a2

Browse files
authored
Merge pull request #36 from dev-protocol/try-lambda
Try lambda
2 parents 35ce4a7 + 26afcf3 commit a46e6a2

File tree

18 files changed

+981
-4476
lines changed

18 files changed

+981
-4476
lines changed

.astro/types.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/build.yml

Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,40 @@
1-
name: Build
1+
name: Release
22

3-
on: [push, pull_request]
3+
on:
4+
workflow_run:
5+
workflows: ['Check']
6+
branches: [main]
7+
types:
8+
- completed
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
413

514
jobs:
6-
build:
15+
release-please:
716
runs-on: ubuntu-latest
17+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
18+
timeout-minutes: 1
19+
outputs:
20+
release_created: ${{ steps.release.outputs.release_created }}
21+
tag_name: ${{ steps.release.outputs.tag_name }}
22+
23+
steps:
24+
- id: release
25+
uses: googleapis/release-please-action@v4
26+
with:
27+
release-type: simple
28+
29+
upload-artifact:
30+
runs-on: ubuntu-latest
31+
needs: release-please
32+
if: ${{ needs.release-please.outputs.release_created }}
33+
timeout-minutes: 5
834

935
strategy:
1036
matrix:
11-
node-version: [18.x]
37+
node-version: [20.x]
1238

1339
steps:
1440
- uses: actions/checkout@v4
@@ -22,8 +48,44 @@ jobs:
2248
corepack enable
2349
yarn
2450
25-
- name: lint
26-
run: yarn lint
51+
- name: Build `lambda` function
52+
run: |
53+
yarn build
54+
echo '{"type": "module"}' > dist/package.json
55+
zip -rj lambda.zip dist
56+
57+
- name: Build `chromium` layer
58+
run: |
59+
mkdir work-chromium
60+
cd work-chromium
61+
git clone --depth=1 https://github.com/sparticuz/chromium.git
62+
cd chromium
63+
make chromium.zip
64+
mv chromium.zip ../../
65+
66+
- name: Build `libs` layer
67+
run: |
68+
mkdir nodejs
69+
rm -rf node_modules
70+
yarn workspaces focus --production
71+
cp -r node_modules nodejs
72+
zip -r libs.zip nodejs
73+
74+
- name: Build `fonts` layer
75+
run: |
76+
mkdir work-fonts
77+
cd work-fonts
78+
git clone --depth=1 git@github.com:dev-protocol/stackroom.git
79+
cd stackroom/fonts
80+
mv IBM_Plex_Sans_JP/* ./
81+
rm -rf IBM_Plex_Sans_JP
82+
mv Noto_Color_Emoji/* ./
83+
rm -rf Noto_Color_Emoji
84+
cd ../
85+
zip -r fonts.zip fonts
86+
mv fonts.zip ../../
2787
28-
- name: test
29-
run: yarn test
88+
- name: Upload Artifact
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
run: gh release upload ${{ needs.release-please.outputs.tag_name }} lambda.zip chromium.zip libs.zip fonts.zip

.github/workflows/check.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Check
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
check:
7+
runs-on: ubuntu-latest
8+
9+
strategy:
10+
matrix:
11+
node-version: [20.x]
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Use Node.js ${{ matrix.node-version }}
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
20+
- name: install deps
21+
run: |
22+
corepack enable
23+
yarn
24+
25+
- name: lint
26+
run: yarn lint

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,6 @@ package-lock.json
108108

109109
# astro
110110
**/.astro
111+
112+
# builds
113+
*.zip

README.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
# template-repos-ts
2-
3-
Template repository for using TypeScript
4-
5-
# Stack
6-
7-
- npm client is [yarn](https://github.com/yarnpkg/yarn)
8-
- Testing is [vitest](https://github.com/vitest-dev/vitest)
9-
- Linting is [eslint](https://github.com/eslint/eslint)
10-
- Basic lint rule set is [eslint-plugin-functional](https://github.com/jonaskello/eslint-plugin-functional)
11-
- Formatter is [prettier](https://github.com/prettier/prettier)
12-
- Pre-install utility is [ramda](https://github.com/ramda/ramda)
13-
14-
# Usage
15-
16-
Create a repository using this template; just runs following command.
17-
18-
```bash
19-
yarn
20-
```
1+
### How to release
2+
3+
1. Download all zip files from a release.
4+
2. Upload all zips to s3://devprotocol-clubs/clubs/\_lambda-layers/place/capture and override them.
5+
3. Access Lambda/Layers/chromium and click `Create version` -> `Upload a file from Amazon S3` and input `https://devprotocol-clubs.s3.us-east-1.amazonaws.com/clubs/_lambda-layers/place/capture/chromium.zip`, set Compatible architectures = x86_64, set Compatible runtimes == Node.js 22.x + Node.js 20.x, then create.
6+
4. Access Lambda/Layers/libs and click `Create version` -> `Upload a file from Amazon S3` and input `https://devprotocol-clubs.s3.us-east-1.amazonaws.com/clubs/_lambda-layers/place/capture/libs.zip`, set Compatible architectures = x86_64, set Compatible runtimes == Node.js 22.x + Node.js 20.x, then create.
7+
5. Access Lambda/Layers/fonts and click `Create version` -> `Upload a file from Amazon S3` and input `https://devprotocol-clubs.s3.us-east-1.amazonaws.com/clubs/_lambda-layers/place/capture/fonts.zip`, set Compatible architectures = x86_64, set Compatible runtimes == Node.js 22.x + Node.js 20.x, then create.
8+
6. Access Lambda/Functions/capture-screenshots and click `Upload from` -> `Amazon S3 location` and input `https://devprotocol-clubs.s3.us-east-1.amazonaws.com/clubs/_lambda-layers/place/capture/lambda.zip`, and edit layers to use all of the latest versions,then publish new version on the console.

astro.config.mjs

Lines changed: 0 additions & 13 deletions
This file was deleted.

chromium/chromium

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit cc370be2db243cb9ee84a6d85e30b6b2b7144282

example/index.test.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

example/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
"description": "Template repository for using TypeScript",
55
"type": "module",
66
"scripts": {
7-
"test": "vitest",
8-
"build": "astro build",
9-
"dev": "astro dev",
7+
"build": "yarn prebuild && rollup -c",
108
"prebuild": "rimraf dist",
119
"lint": "yarn lint:eslint && yarn lint:format",
1210
"lint:eslint": "eslint . --fix",
@@ -16,21 +14,22 @@
1614
"author": "Dev Protocol",
1715
"license": "MPL-2.0",
1816
"dependencies": {
19-
"@astrojs/netlify": "^6.1.0",
20-
"@astrojs/vercel": "8.0.4",
2117
"@devprotocol/util-ts": "^4.0.0",
22-
"@sparticuz/chromium-min": "^130.0.0",
23-
"astro": "5.1.10",
24-
"puppeteer-core": "23.6.0",
25-
"ramda": "0.30.1"
18+
"@sparticuz/chromium": "^132.0.0",
19+
"aws-lambda": "^1.0.7",
20+
"puppeteer-core": "23.6.0"
2621
},
2722
"devDependencies": {
2823
"@eslint/js": "^9.12.0",
24+
"@rollup/plugin-commonjs": "^28.0.2",
25+
"@rollup/plugin-json": "^6.1.0",
26+
"@rollup/plugin-node-resolve": "^16.0.0",
27+
"@rollup/plugin-typescript": "^12.1.2",
28+
"@types/aws-lambda": "^8.10.147",
2929
"@types/dotenv": "8.2.3",
3030
"@types/eslint-config-prettier": "^6.11.3",
3131
"@types/eslint__js": "^8.42.3",
3232
"@types/node": "22.7.9",
33-
"@types/ramda": "0.30.2",
3433
"dotenv": "16.4.5",
3534
"eslint": "^9.12.0",
3635
"eslint-config-prettier": "^9.1.0",
@@ -39,9 +38,9 @@
3938
"husky": "9.1.6",
4039
"prettier": "3.3.3",
4140
"rimraf": "6.0.1",
41+
"rollup": "^4.32.1",
4242
"typescript": "5.6.3",
43-
"typescript-eslint": "^8.9.0",
44-
"vitest": "^2.1.3"
43+
"typescript-eslint": "^8.9.0"
4544
},
4645
"repository": "git+https://github.com/dev-protocol/template-repos-ts.git",
4746
"bugs": {

0 commit comments

Comments
 (0)