aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/updateInvidous.yml32
-rw-r--r--.gitignore2
-rw-r--r--ci/invidiousCI.ts (renamed from src/ci/invidiousCI.ts)9
-rw-r--r--ci/invidiouslist.json (renamed from src/ci/invidiouslist.json)0
-rw-r--r--package.json2
-rw-r--r--src/config.ts2
6 files changed, 42 insertions, 5 deletions
diff --git a/.github/workflows/updateInvidous.yml b/.github/workflows/updateInvidous.yml
new file mode 100644
index 00000000..f43142c7
--- /dev/null
+++ b/.github/workflows/updateInvidous.yml
@@ -0,0 +1,32 @@
+name: update invidious
+on:
+ workflow_dispatch:
+ schedule:
+ - cron: '0 0 1 * *' # check every month
+
+jobs:
+ check-list:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Download instance list
+ run: |
+ wget https://api.invidious.io/instances.json -O data.json
+ - name: "Run CI"
+ run: npm run ci:invidious
+ - name: setup git config
+ run: |
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+ - name: "Commit new files"
+ run : |
+ if [ $(git status --porcelain=v1 2>/dev/null | wc -l) -ge 1 ]
+ then
+ echo "pushing changes"
+ git add invidiouslist.json
+ git commit -m "[CI] New Invidious List"
+ git push origin main
+ else
+ echo "no changes"
+ fi \ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 3dcdb226..2eafbe10 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@ web-ext-artifacts
dist/
tmp/
.DS_Store
-src/ci/data.json \ No newline at end of file
+ci/data.json \ No newline at end of file
diff --git a/src/ci/invidiousCI.ts b/ci/invidiousCI.ts
index 2c4a8089..05cf8f8f 100644
--- a/src/ci/invidiousCI.ts
+++ b/ci/invidiousCI.ts
@@ -4,10 +4,15 @@ This file is only ran by GitHub Actions in order to populate the Invidious insta
This file should not be shipped with the extension
*/
-import { writeFile } from 'fs';
+import { writeFile, existsSync } from 'fs';
import { join } from 'path';
-// import file downloade from https://api.invidious.io/instances.json
+// import file from https://api.invidious.io/instances.json
+if (!existsSync('./data.json')) {
+ process.exit(1);
+}
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
import * as data from "./data.json";
type instanceMap = {
diff --git a/src/ci/invidiouslist.json b/ci/invidiouslist.json
index 905605d8..905605d8 100644
--- a/src/ci/invidiouslist.json
+++ b/ci/invidiouslist.json
diff --git a/package.json b/package.json
index 963c1203..62153f13 100644
--- a/package.json
+++ b/package.json
@@ -52,7 +52,7 @@
"build:watch": "npm run build:watch:chrome",
"build:watch:chrome": "webpack --env.browser=chrome --config webpack/webpack.dev.js --watch",
"build:watch:firefox": "webpack --env.browser=firefox --config webpack/webpack.dev.js --watch",
- "ci:invidious": "ts-node src/ci/invidiousCI.ts",
+ "ci:invidious": "ts-node ci/invidiousCI.ts",
"dev": "npm run build:dev && concurrently \"npm run web-run\" \"npm run build:watch\"",
"dev:firefox": "npm run build:dev:firefox && concurrently \"npm run web-run:firefox\" \"npm run build:watch:firefox\"",
"dev:firefox-android": "npm run build:dev:firefox && concurrently \"npm run web-run:firefox-android\" \"npm run build:watch:firefox\"",
diff --git a/src/config.ts b/src/config.ts
index 912f87dc..814e95a6 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -1,5 +1,5 @@
import * as CompileConfig from "../config.json";
-import * as invidiousList from "../src/ci/invidiouslist.json";
+import * as invidiousList from "../ci/invidiouslist.json";
import { Category, CategorySelection, CategorySkipOption, NoticeVisbilityMode, PreviewBarOption, SponsorTime, StorageChangesObject, UnEncodedSegmentTimes as UnencodedSegmentTimes } from "./types";
interface SBConfig {