diff --git a/.circleci/config.yml b/.circleci/config.yml index bb176b74..14ab0b45 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,27 +29,63 @@ jobs: steps: - checkout - run: - name: Install dependencies + name: Install root dependencies command: | sudo npm install -g pnpm pnpm install --frozen-lockfile + - run: + name: Install functions dependencies + command: | + cd functions + npm install - run: name: Run linting command: | cd functions npm run lint -- --max-warnings 0 - run: - name: TypeScript type check + name: TypeScript type check (functions) command: | cd functions npx tsc --noEmit + - run: + name: TypeScript type check (worker) + command: npx tsc --noEmit - run: name: Quality GC check command: npx quality-gc run || echo "Quality GC issues found" + deploy-worker: + docker: + - image: cimg/node:20.18 + steps: + - checkout + - run: + name: Install pnpm + command: sudo npm install -g pnpm + - run: + name: Install dependencies + command: pnpm install --frozen-lockfile + - run: + name: Deploy YouTube Worker to Cloudflare + command: npx wrangler deploy src/youtube-worker.ts --name ytstudio + environment: + CLOUDFLARE_API_TOKEN: $CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID: $CLOUDFLARE_ACCOUNT_ID + workflows: version: 2 + validate: jobs: - python-checks - node-checks + + deploy: + jobs: + - deploy-worker: + filters: + branches: + only: main + context: + - cloudflare diff --git a/fix_app.py b/fix_app.py index 247998d2..610efb43 100644 --- a/fix_app.py +++ b/fix_app.py @@ -1,7 +1,6 @@ -import sys -filepath = 'js/app.js' -with open(filepath, 'r') as f: +filepath = "js/app.js" +with open(filepath) as f: lines = f.readlines() # Part 1: DOM elements @@ -31,5 +30,5 @@ lines.insert(i + idx, new_line) break -with open(filepath, 'w') as f: +with open(filepath, "w") as f: f.writelines(lines) diff --git a/fix_deps.py b/fix_deps.py index 34cbd976..f59b27b2 100644 --- a/fix_deps.py +++ b/fix_deps.py @@ -15,12 +15,12 @@ # Maybe the CI is running against a different state of the PR? # Let's just make sure trigger-circleci-pipeline and circletui are in package.json if they are in the lockfile. -if 'dependencies' not in pkg: - pkg['dependencies'] = {} +if "dependencies" not in pkg: + pkg["dependencies"] = {} -pkg['dependencies']['trigger-circleci-pipeline'] = '^1.12.1' -pkg['dependencies']['circletui'] = '^1.0.3' -pkg['dependencies']['@circleci/circleci-config-sdk'] = '^0.12.5' +pkg["dependencies"]["trigger-circleci-pipeline"] = "^1.12.1" +pkg["dependencies"]["circletui"] = "^1.0.3" +pkg["dependencies"]["@circleci/circleci-config-sdk"] = "^0.12.5" with Path("package.json").open("w") as f: json.dump(pkg, f, indent=2) diff --git a/fix_index.py b/fix_index.py index 353b69c1..5e73c769 100644 --- a/fix_index.py +++ b/fix_index.py @@ -1,10 +1,10 @@ -with open('index.html', 'r') as f: +with open("index.html") as f: content = f.read() # Add title attribute to search button -old_search = '