Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mnekoei patch 1 #100

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 21 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,35 @@
name: Build worker.js
name: Deploy Worker

on:
push:
branches: ["main"]
release:
types: ["published"]
repository_dispatch:

jobs:
build:
permissions:
contents: write

deploy:
runs-on: ubuntu-latest

timeout-minutes: 60

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v3
with:
node-version: "latest"
node-version: "18"
cache: "npm"

- name: Install modules
run: npm i wrangler@latest

- name: Build
run: npx wrangler build
- name: Install Wrangler
run: npm install -g wrangler@latest

- name: Add Header
run: cp ${{ github.workspace }}/dist/worker.js ${{ github.workspace }}/dist/worker-original.js && echo -e "/*!\r\n * v2ray Subscription Worker (${{ github.sha }})\r\n * Copyright 2024 Vahid Farid (https://twitter.com/vahidfarid)\r\n * Licensed under GPLv3 (https://github.com/vfarid/v2ray-worker/blob/main/Licence.md)\r\n */\r\n" > ${{ github.workspace }}/dist/worker.js && cat ${{ github.workspace }}/dist/worker-original.js >> ${{ github.workspace }}/dist/worker.js

- name: Upload to Artifacts
uses: actions/upload-artifact@v4
with:
name: worker
path: ${{ github.workspace }}/dist/worker.js
run: |
cp $GITHUB_WORKSPACE/worker.js $GITHUB_WORKSPACE/dist/worker-original.js
echo -e "/*!\n * v2ray Subscription Worker ($GITHUB_SHA)\n * Copyright 2024 Vahid Farid (https://twitter.com/vahidfarid)\n * Licensed under GPLv3 (https://github.com/vfarid/v2ray-worker/blob/main/Licence.md)\n */\n\n$(cat $GITHUB_WORKSPACE/dist/worker.js)" > $GITHUB_WORKSPACE/dist/worker.js

- name: Add Release Header
run: echo -e "/*!\r\n * v2ray Subscription Worker ${{ github.event.release.tag_name }}\r\n * Copyright 2024 Vahid Farid (https://twitter.com/vahidfarid)\r\n * Licensed under GPLv3 (https://github.com/vfarid/v2ray-worker/blob/main/Licence.md)\r\n */\r\n" > ${{ github.workspace }}/dist/worker.js && cat ${{ github.workspace }}/dist/worker-original.js >> ${{ github.workspace }}/dist/worker.js

- name: Upload to GitHub Release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ github.workspace }}/dist/worker.js
asset_name: worker.js
tag: ${{ github.ref }}
overwrite: true
- name: Set environment variables
run: echo "KV_NAME=${{ secrets.KV_NAME }}" >> $GITHUB_ENV

- name: Deploy
run: |
sed -i "s/KV_NAME/$KV_NAME/g" wrangler.toml
wrangler deploy --api-token ${{ secrets.CF_API_TOKEN }} --account-id ${{ secrets.CF_ACCOUNT_ID }}
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ jobs:
cache: "npm"

- name: Install modules
run: npm i wrangler@latest
run: npm i @cloudflare/wrangler

- name: Build
run: npx wrangler build
# - name: Build
# run: npx wrangler build

- name: Add Header
run: cp ${{ github.workspace }}/dist/worker.js ${{ github.workspace }}/dist/worker-original.js && echo -e "/*!\n * v2ray Subscription Worker (${{ github.sha }})\n * Copyright 2024 Vahid Farid (https://twitter.com/vahidfarid)\n * Licensed under GPLv3 (https://github.com/vfarid/v2ray-worker/blob/main/Licence.md)\n */\n\n$(cat ${{ github.workspace }}/dist/worker.js)" > ${{ github.workspace }}/dist/worker.js

- name: Deploy
run: sed -i "s/KV_NAME/{{ secrets.KV_NAME }}/g" wrangler.toml && wrangler deploy --api-token ${{ secrets.CF_API_TOKEN }} --account-id ${{ secrets.CF_ACCOUNT_ID }}
run: sed -i "s/KV_NAME/{{ secrets.KV_NAME }}/g" wrangler.toml && npx wrangler deploy --api-token ${{ secrets.CF_API_TOKEN }} --account-id ${{ secrets.CF_ACCOUNT_ID }}

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ To be completed...
1. Fork this Repo and enable Github Action
2. Open CloudFlare and create KV namespace with name `settings` then copy the ID
3. Go to this forked repo and set secrets with name `KV_NAME` and fill with KV settings ID
4. Edit this `README.md` file, then find and replace this button url bellow with yours `https://github.com/USER/REPO_NAME` then save it.
4. Edit this `README.md` file, then find and replace this button url bellow with yours `https://github.com/mnekoei/v2ray-worker` then save it.
4. then press `Deploy With Workers` and follow the instruction

[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/vfarid/v2ray-worker)
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/mnekoei/v2ray-worker)

### Credits
Built-in vless config generator is based on [Zizifn Edge Tunnel](https://github.com/zizifn/edgetunnel), re-written using Typescript.
Expand Down