Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad-2213 authored Oct 23, 2024
0 parents commit ae177bc
Show file tree
Hide file tree
Showing 15 changed files with 1,770 additions and 0 deletions.
106 changes: 106 additions & 0 deletions .github/workflows/cf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: ⛅ CF Worker
on:
# docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
# docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_dispatch
# docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_dispatchinputs
workflow_dispatch:
# github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
# docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs
inputs:
# docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatchinputs
environment:
description: 'wrangler env to deploy to'
required: true
default: 'dev'
type: choice
options:
- dev
- prod
- one
commit:
description: 'git tip commit to deploy'
default: 'main'
required: true

push:
# TODO: inputs.environment and inputs.commit
branches:
- "main"
tags:
- "v*"
paths-ignore:
- ".github/**"
- "!.github/workflows/cf.yml"
- ".env.example"
- ".eslintrc.cjs"
- ".prettierignore"
- "fly.toml"
- "README.md"
- "node.Dockerfile"
- "deno.Dockerfile"
- "import_map.json"
- ".vscode/*"
- ".husky/*"
- ".prettierrc.json"
- "LICENSE"
- "run"
repository_dispatch:

env:
GIT_REF: ${{ github.event.inputs.commit || github.ref }}
# default is 'dev' which is really empty/no env
WORKERS_ENV: ''

jobs:
deploy:
name: 🚀 Deploy worker
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v3.3.0
with:
ref: ${{ env.GIT_REF }}
fetch-depth: 0

- name: 🛸 Env?
# 'dev' env deploys to default WORKERS_ENV, which is, '' (an empty string)
if: github.event.inputs.environment == 'prod' || github.event.inputs.environment == 'one'
run: |
echo "WORKERS_ENV=${WENV}" >> $GITHUB_ENV
echo "COMMIT_SHA=${COMMIT_SHA}" >> $GITHUB_ENV
shell: bash
env:
WENV: ${{ github.event.inputs.environment }}
COMMIT_SHA: ${{ github.sha }}

- name: 🎱 Tag?
# docs.github.com/en/actions/learn-github-actions/contexts#github-context
if: github.ref_type == 'tag'
run: |
echo "WORKERS_ENV=${WENV}" >> $GITHUB_ENV
echo "COMMIT_SHA=${COMMIT_SHA}" >> $GITHUB_ENV
shell: bash
env:
# tagged deploys always deploy to prod
WENV: 'prod'
COMMIT_SHA: ${{ github.sha }}

# npm (and node16) are installed by wrangler-action in a pre-job setup
- name: 🏗 Get dependencies
run: npm i

- name: 📚 Wrangler publish
# github.com/cloudflare/wrangler-action
uses: cloudflare/wrangler-action@2.0.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
# input overrides env-defaults, regardless
environment: ${{ env.WORKERS_ENV }}
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
GIT_COMMIT_ID: ${{ env.GIT_REF }}

- name: 🎤 Notice
run: |
echo "::notice::Deployed to ${WORKERS_ENV} / ${GIT_REF} @ ${COMMIT_SHA}"
39 changes: 39 additions & 0 deletions .github/workflows/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "🌲 Create many branches"

on:
workflow_dispatch:

jobs:
create_branches:
runs-on: ubuntu-latest
name: "🌲 Create and push branches"
env:
EMAIL: ${{ secrets.GH_EMAIL }}
NAME: ${{ secrets.GH_USERNAME }}
TOKEN: ${{ secrets.TOKEN }}
REMOTE_NAME: origin
BRANCH_BASE_NAME: proxyip
BRANCH_COUNT: 300

steps:
- name: ⚙️ Set up Git config
run: |
git config --global user.email "${{ env.EMAIL }}"
git config --global user.name "${{ env.NAME }}"
- name: 📦 Clone repository
run: |
git clone https://${{ env.TOKEN }}@github.com/${{github.repository}}.git
cd $(echo ${{github.repository}} | awk -F'/' '{print $2}')
- name: 🌿 Create and push branches
run: |
cd $(echo ${{github.repository}} | awk -F'/' '{print $2}')
for ((i=1; i<=${{ env.BRANCH_COUNT }}; i++)); do
branch_name="${{ env.BRANCH_BASE_NAME }}${i}"
git branch $branch_name
git checkout $branch_name
git commit --allow-empty -m "Create branch ${branch_name}"
git push ${{ env.REMOTE_NAME }} $branch_name
git checkout main
done
52 changes: 52 additions & 0 deletions .github/workflows/obfuscator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Obfuscate and Commit

on:
push:
branches: [main]
workflow_dispatch:

jobs:
obfuscate:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16"

- name: Install dependencies
run: npm install -g javascript-obfuscator

- name: Obfuscate code
run: |
javascript-obfuscator index.js --output _worker.js \
--compact true \
--control-flow-flattening true \
--control-flow-flattening-threshold 1 \
--dead-code-injection true \
--dead-code-injection-threshold 1 \
--string-array true \
--string-array-encoding 'rc4' \
--string-array-threshold 1 \
--transform-object-keys true \
--unicode-escape-sequence true
- name: Commit changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add _worker.js
git commit -m "Obfuscate _worker.js" || echo "No changes to commit"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
40 changes: 40 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "🔄 Sync all branches with main"

on:
workflow_dispatch:

jobs:
sync_branches:
runs-on: ubuntu-latest
name: "🔄 Sync branches with main"
env:
EMAIL: ${{ secrets.GH_EMAIL }}
NAME: ${{ secrets.GH_USERNAME }}
TOKEN: ${{ secrets.TOKEN }}
REMOTE_NAME: origin
BRANCH_BASE_NAME: proxyip
BRANCH_COUNT: 200

steps:
- name: 🛠 Set up Git config
run: |
git config --global user.email "${{ env.EMAIL }}"
git config --global user.name "${{ env.NAME }}"
- name: 📥 Clone repository
run: |
git clone https:///${{ env.TOKEN }}@github.com/${{github.repository}}.git
cd $(echo ${{github.repository}} | awk -F'/' '{print $2}')
- name: 🔄 Sync and push branches
run: |
cd $(echo ${{github.repository}} | awk -F'/' '{print $2}')
git checkout main
git pull ${REMOTE_NAME} main
for ((i=1; i<=${{ env.BRANCH_COUNT }}; i++)); do
branch_name="${{ env.BRANCH_BASE_NAME }}${i}"
git checkout $branch_name
git merge main --no-edit
git push ${REMOTE_NAME} $branch_name
git checkout main
done
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log
.wrangler
# Dependency directories
node_modules/

# Environment variables
.env

# Build output
build/
dist/

# IDE files
.vscode/
.idea/
*.sublime-project
*.sublime-workspace

# Miscellaneous
.DS_Store
Thumbs.db
.env
node_modules/
package-lock.json
socks5.js
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 3Kmfi6HP

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit ae177bc

Please sign in to comment.