Skip to content

fix: fixed deploy_to_cf_workers workflow and others#104

Open
mdrkrg wants to merge 2 commits intovfarid:mainfrom
mdrkrg:fix/deploy
Open

fix: fixed deploy_to_cf_workers workflow and others#104
mdrkrg wants to merge 2 commits intovfarid:mainfrom
mdrkrg:fix/deploy

Conversation

@mdrkrg
Copy link

@mdrkrg mdrkrg commented Feb 18, 2025

Overview of the problem

Wrangler has dropped support of flag --api-token and --account-id. And the current workflow also has the problem that sed not substituding with secret, and using global wrangler instead of npx wrangler.

This PR only resolves the deployment problem, and doesn't resolve Worker 1011 problem.

Changes

The major change is changing wrangler deploy to npx wrangler deploy (problem of #93) and adding the missing variable reference ${{ secrets.KV_NAME }}.

I've also removed no longer supported --api-token and --account-id and uses variables CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_TOKEN instead.

-    - 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 }}
+    - name: Deploy
+      run: |
+        sed -i "s/V2RAY_WORKER_KV_ID/${{ secrets.V2RAY_WORKER_KV_ID }}/g" wrangler.toml \
+        && npx wrangler deploy
+      env:
+        CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
+        CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

Some other changes of this PR:

  • improved and provided with a zh_CN version of README.md
  • edited wrangler.toml
    • use a more semantic namespace v2ray_worker_settings
    • changed KV_NAME to V2RAY_WORKER_KV_ID
    • bumped compatibility_date

Notes

Please be cautious that I haven't tested the deployed worker yet. If there's any compability issues related to Cloudflare API compatiblity date just revert that line of code back to compatibility_date = "2024-05-29".

The README-fa.md is also not updated.

* changed deprecated `wrangler build` with `deploy --dry-run`

* use env to set `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID`

* renamed namespace `settings` to `v2ray_worker_settings`

* update wrangler.toml to use `V2RAY_WORKER_KV_ID` secret

* bump `compatibility_date` to 2025-02-18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant