add cf worker hello world project and enable deploy via GITHUB action (#78)

add cf worker hello world project and enable deploy via GITHUB action
This commit is contained in:
zizifn 2022-12-18 01:33:12 +08:00 committed by GitHub
parent e2a69de47f
commit 72567f8cbf
13 changed files with 5330 additions and 157 deletions

37
.github/workflows/cf-worker-deploy.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: cf-worker-deploy
on:
push:
branches:
- main
- test-cf
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
environment: CF
name: Deploy
steps:
- uses: actions/checkout@v2
- name: envsubst
run: |
envsubst < apps/cf-worker-vless/wrangler.toml.tp > apps/cf-worker-vless/wrangler.toml
if [[ $CUSTOM_DOMAIN ]]; then
echo cf_environment="custom" >> $GITHUB_ENV
else
echo "not set CUSTOM_DOMAIN"
fi
env:
CUSTOM_DOMAIN: ${{ secrets.CUSTOM_DOMAIN }}
- name: Publish
uses: cloudflare/wrangler-action@2.0.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
command: publish --env ${{ env.cf_environment || 'default' }}
workingDirectory: 'apps/cf-worker-vless'
environment: ${{ env.cf_environment || 'default' }}
secrets: |
UUID
env:
UUID: ${{ secrets.UUID }}

3
.gitignore vendored
View File

@ -42,3 +42,6 @@ Thumbs.db
**/config-local.json
**/.env
**/.dev.vars
**/wrangler.toml

View File

@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

View File

@ -0,0 +1,23 @@
{
"name": "cf-worker-vless",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/cf-worker-vless/src",
"projectType": "application",
"targets": {
"serve": {
"executor": "nx:run-commands",
"options": {
"command": "wrangler dev",
"cwd": "apps/cf-worker-vless"
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/cf-worker-vless/**/*.ts"]
}
}
},
"tags": []
}

View File

View File

View File

@ -0,0 +1,3 @@
export const environment = {
production: true,
};

View File

@ -0,0 +1,3 @@
export const environment = {
production: false,
};

View File

@ -0,0 +1,9 @@
export default {
async fetch(request: Request, env: any) {
return new Response(
`request method111: ${request.method}, and env is ${JSON.stringify(
env
)} ${Date()}`
);
},
};

View File

@ -0,0 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"noEmit": true,
"module": "esnext",
"target": "es2020",
"lib": ["es2020"],
"strict": true,
"alwaysStrict": true,
"preserveConstEnums": true,
"moduleResolution": "node",
"sourceMap": true,
"types": ["@cloudflare/workers-types", "@types/jest"]
},
"include": ["src"],
"exclude": ["node_modules", "dist", "test"],
"references": [
{
"path": "./tsconfig.app.json"
}
]
}

View File

@ -0,0 +1,21 @@
name = "edge-tunnel-vless" # todo
main = "./src/main.ts"
compatibility_date = "2022-05-03"
workers_dev = true # should be deployed to *.workers.dev
[vars]
TEST_VAR = "example_dev_token"
[env.default]
name = "edge-tunnel-vless"
workers_dev = true # should be deployed to *.workers.dev
[env.default.vars]
TEST_VAR = "TEST_VAR_DEFAULT"
[env.custom]
name = "edge-tunnel-vless"
routes = [{ pattern = "$CUSTOM_DOMAIN", custom_domain = true }]
[env.custom.vars]
TEST_VAR = "TEST_VAR_CUSTOM"

5336
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -17,17 +17,21 @@
"react-dom": "18.2.0",
"tslib": "^2.3.0",
"undici": "^5.13.0",
"uuid": "^9.0.0"
"uuid": "^9.0.0",
"wrangler": "^2.6.2"
},
"devDependencies": {
"@cloudflare/workers-types": "^3.0.0",
"@nrwl/cli": "15.2.4",
"@nrwl/cypress": "^15.3.3",
"@nrwl/eslint-plugin-nx": "15.2.4",
"@nrwl/jest": "^15.3.3",
"@nrwl/js": "^15.3.3",
"@nrwl/linter": "15.2.4",
"@nrwl/node": "15.2.4",
"@nrwl/react": "15.3.3",
"@nrwl/vite": "15.3.3",
"@nrwl/web": "^15.3.3",
"@nrwl/webpack": "^15.3.3",
"@nrwl/workspace": "15.2.4",
"@testing-library/react": "13.4.0",
@ -55,7 +59,8 @@
"nx": "15.2.4",
"pkg": "^5.8.0",
"postcss": "^8.4.20",
"prettier": "^2.6.2",
"prettier": "2.8.1",
"prettier-plugin-toml": "0.3.1",
"react-test-renderer": "18.2.0",
"tailwindcss": "^3.2.4",
"ts-jest": "28.0.5",
@ -64,6 +69,7 @@
"vite": "^3.0.5",
"vite-plugin-eslint": "^1.6.0",
"vite-tsconfig-paths": "^4.0.1",
"vitest": "^0.25.1"
"vitest": "^0.25.1",
"wrangler": "^2.1.14"
}
}