From da02a966fb7e66dbb70e555c1c11b2de89bbe508 Mon Sep 17 00:00:00 2001 From: Viet Huynh Date: Fri, 29 Sep 2023 06:18:30 +0700 Subject: [PATCH] add npm scripts --- auto_update_github_action.yml | 16 ++++++---------- package.json | 13 +++++++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/auto_update_github_action.yml b/auto_update_github_action.yml index cd36700..525549b 100644 --- a/auto_update_github_action.yml +++ b/auto_update_github_action.yml @@ -33,20 +33,18 @@ jobs: - name: Install npm dependencies run: npm ci - - name: Download recommended whitelist - run: bash ./get_recommended_whitelist.sh + - name: Download allowlists + run: npm run download:allowlist env: ALLOWLIST_URLS: ${{ vars.ALLOWLIST_URLS }} - - name: Download recommended filters - run: bash ./get_recommended_filters.sh + - name: Download blocklists + run: npm run download:blocklist env: BLOCKLIST_URLS: ${{ vars.BLOCKLIST_URLS }} - name: Delete old rules and lists - run: | - node cf_gateway_rule_delete.js - node cf_list_delete.js + run: npm run cloudflare-delete env: CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }} CLOUDFLARE_ACCOUNT_EMAIL: ${{ secrets.CLOUDFLARE_ACCOUNT_EMAIL }} @@ -55,9 +53,7 @@ jobs: FAST_MODE: ${{ vars.FAST_MODE }} - name: Create new rules and lists - run: | - node cf_list_create.js - node cf_gateway_rule_create.js + run: npm run cloudflare-create env: CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }} CLOUDFLARE_ACCOUNT_EMAIL: ${{ secrets.CLOUDFLARE_ACCOUNT_EMAIL }} diff --git a/package.json b/package.json index 4b98eef..03e3d8c 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,17 @@ { + "scripts": { + "start": "npm run download && npm run cloudflare-delete && npm run cloudflare-create", + "dry": "npm run download && DRY_RUN=1 npm run cloudflare-create:list", + "download": "node download_lists.js", + "download:allowlist": "node download_lists.js allowlist", + "download:blocklist": "node download_lists.js blocklist", + "cloudflare-create": "npm run create:list && npm run create:rule", + "cloudflare-delete": "npm run delete:rule && npm run delete:list", + "cloudflare-create:rule": "node cf_gateway_rule_create.js", + "cloudflare-create:list": "node cf_list_create.js", + "cloudflare-delete:rule": "node cf_gateway_rule_delete.js", + "cloudflare-delete:list": "node cf_list_delete.js" + }, "type": "module", "dependencies": { "dotenv": "^16.0.3",