From 7266ddb24d022951640d1f113444f41181bb46e0 Mon Sep 17 00:00:00 2001 From: ByMykel Date: Fri, 9 Feb 2024 20:16:13 +0100 Subject: [PATCH] refactor: test workflows. --- .github/workflows/deploy.yml | 4 ++-- .github/workflows/group.yml | 11 ++++------- .github/workflows/update.yml | 9 ++++----- group.js | 27 --------------------------- manifestIdGroup.txt | 1 - manifestIdUpdate.txt | 1 - services/main.js | 11 ----------- update.js | 30 +----------------------------- 8 files changed, 11 insertions(+), 83 deletions(-) delete mode 100644 manifestIdGroup.txt delete mode 100644 manifestIdUpdate.txt diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8173fd828..3bf3a4e42 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,8 +14,8 @@ jobs: - run: | git init git add -A - git config --local user.email "action@github.com" - git config --local user.name "github-actions[bot]" + git config --local user.email "github-actions[bot]" + git config --local user.name "41898282+github-actions[bot]@users.noreply.github.com" git commit -m 'deploy' working-directory: ./public - uses: JamesIves/github-pages-deploy-action@v4.3.3 diff --git a/.github/workflows/group.yml b/.github/workflows/group.yml index ad89ed2de..9c49d794c 100644 --- a/.github/workflows/group.yml +++ b/.github/workflows/group.yml @@ -14,14 +14,11 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 - - name: Install - run: npm install - - name: Generate new data - run: npm run group-data - - name: Commit & push changes - run: | + - run: npm install + - run: npm run group-data + - run: | git config user.name 'github-actions[bot]' git config user.email '41898282+github-actions[bot]@users.noreply.github.com' git add . - git diff --quiet && git diff --staged --quiet || git commit -m "group data" + git diff --quiet && git diff --staged --quiet || git commit -m "[bot] Group JSON API" git push origin main diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 0fcfe332b..7969d4032 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -14,12 +14,11 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 18 - - name: Generate new data - run: npm install && npm run update-data - - name: Commit & push changes - run: | + - run: npm install + - run: npm run update-data + - run: | git config user.name 'github-actions[bot]' git config user.email '41898282+github-actions[bot]@users.noreply.github.com' git add . - git diff --quiet && git diff --staged --quiet || git commit -m "update data" + git diff --quiet && git diff --staged --quiet || git commit -m "[bot] Update JSON API" git push origin main diff --git a/group.js b/group.js index fb7fefe09..09dc9dd74 100644 --- a/group.js +++ b/group.js @@ -1,7 +1,6 @@ import fs from "fs"; import path from "path"; import { LANGUAGES_URL } from "./constants.js"; -import { getManifestId } from "./services/main.js"; const inputFilePathsTemplate = [ "./public/api/{lang}/agents.json", @@ -17,26 +16,6 @@ const inputFilePathsTemplate = [ "./public/api/{lang}/tools.json", ]; -let existingManifestId = ""; -const latestManifestId = await getManifestId(); - -try { - existingManifestId = fs.readFileSync("./manifestIdGroup.txt"); -} catch (err) { - if (err.code != "ENOENT") { - throw err; - } -} - -if (existingManifestId == latestManifestId) { - console.log("Latest manifest Id matches existing manifest Id, exiting"); - process.exit(0); -} else { - console.log( - "Latest manifest Id does not match existing manifest Id, generating new data." - ); -} - for (let langObj of LANGUAGES_URL) { const lang = langObj.folder; const allData = {}; @@ -66,9 +45,3 @@ for (let langObj of LANGUAGES_URL) { console.log(`all.json for ${lang} has been generated.`); } - -try { - fs.writeFileSync("./manifestIdGroup.txt", latestManifestId.toString()); -} catch (err) { - throw err; -} diff --git a/manifestIdGroup.txt b/manifestIdGroup.txt deleted file mode 100644 index 532f40ab9..000000000 --- a/manifestIdGroup.txt +++ /dev/null @@ -1 +0,0 @@ -578205631086395800 \ No newline at end of file diff --git a/manifestIdUpdate.txt b/manifestIdUpdate.txt deleted file mode 100644 index 532f40ab9..000000000 --- a/manifestIdUpdate.txt +++ /dev/null @@ -1 +0,0 @@ -578205631086395800 \ No newline at end of file diff --git a/services/main.js b/services/main.js index fd4fe97b1..9034e2364 100644 --- a/services/main.js +++ b/services/main.js @@ -635,17 +635,6 @@ const getItemFromKey = (key) => { } }; -export const getManifestId = async () => { - return axios - .get( - "https://raw.githubusercontent.com/ByMykel/counter-strike-file-tracker/main/static/manifestId.txt" - ) - .then((data) => data.data) - .catch(() => { - throw new Error(`Error loading latest manifest Id`); - }); -}; - export const loadData = async () => { await loadItemsGame(); loadPrefabs(); diff --git a/update.js b/update.js index e4b70ee10..dcb8c7570 100644 --- a/update.js +++ b/update.js @@ -1,6 +1,4 @@ -import * as fs from "fs"; - -import { loadData, getManifestId } from "./services/main.js"; +import { loadData } from "./services/main.js"; import { getCollectibles } from "./services/collectibles.js"; import { getKeys } from "./services/keys.js"; import { getAgents } from "./services/agents.js"; @@ -16,26 +14,6 @@ import { getMusicKits } from "./services/musicKits.js"; import { getSkinsNotGrouped } from "./services/skinsNotGrouped.js"; import { getTools } from "./services/tools.js"; -let existingManifestId = ""; -const latestManifestId = await getManifestId(); - -try { - existingManifestId = fs.readFileSync("./manifestIdUpdate.txt"); -} catch (err) { - if (err.code != "ENOENT") { - throw err; - } -} - -if (existingManifestId == latestManifestId) { - console.log("Latest manifest Id matches existing manifest Id, exiting"); - process.exit(0); -} else { - console.log( - "Latest manifest Id does not match existing manifest Id, generating new data." - ); -} - await loadData(); for (const language of LANGUAGES_URL) { @@ -60,9 +38,3 @@ for (const language of LANGUAGES_URL) { console.log(error); } } - -try { - fs.writeFileSync("./manifestIdUpdate.txt", latestManifestId.toString()); -} catch (err) { - throw err; -}