From 406733d664b878a8f0d97000012183bf2d254de5 Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Tue, 16 Apr 2024 20:43:54 +0800 Subject: [PATCH] chore: recover workflow (#116) --- .github/workflows/fetch_token_list.yml | 68 ++++++++++++++++++++++++++ package.json | 2 +- src/index.ts | 6 +-- 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/fetch_token_list.yml diff --git a/.github/workflows/fetch_token_list.yml b/.github/workflows/fetch_token_list.yml new file mode 100644 index 00000000..7f3ef72a --- /dev/null +++ b/.github/workflows/fetch_token_list.yml @@ -0,0 +1,68 @@ +name: Fetch token list + +on: + push: + branches: + - master + +jobs: + fetch-list: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use node_modules cache + uses: actions/cache@v2 + id: npm-cache + with: + path: | + node_modules + key: npm-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + + - name: NPM install + run: npm install + if: steps.npm-cache.outputs.cache-hit != 'true' + + - name: Fetch Token Lists + run: | + npx ts-node ./src/index.ts + + - name: Get Package Version + id: package-version + uses: martinbeentjes/npm-get-version-action@master + + - name: Create version folder + run: | + cp -r ./dist/latest ./dist/v${{ steps.package-version.outputs.current-version }} + + - name: Tag Package Version + run: git tag v${{ steps.package-version.outputs.current-version }} + + - name: Create Release Package + uses: montudor/action-zip@v1 + with: + args: + zip -qq -r v${{ steps.package-version.outputs.current-version }}.zip dist/v${{ + steps.package-version.outputs.current-version }} + + - name: Upload Latest Release + uses: actions/upload-artifact@v2 + with: + name: v${{ steps.package-version.outputs.current-version }}.zip + path: v${{ steps.package-version.outputs.current-version }}.zip + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: v${{ steps.package-version.outputs.current-version }}.zip + asset_name: v${{ steps.package-version.outputs.current-version }}.zip + tag: v${{ steps.package-version.outputs.current-version }} + overwrite: true + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist + keep_files: true + cname: tokens.r2d2.to \ No newline at end of file diff --git a/package.json b/package.json index 3b52087e..16715655 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mask-token-lists", - "version": "0.0.68", + "version": "0.0.74", "repository": "https://github.com/DimensionDev/Mask-Token-Lists.git", "license": "MIT", "author": "guanbinrui ", diff --git a/src/index.ts b/src/index.ts index a40784a9..b3c224c1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,9 +13,9 @@ async function main() { console.log(`[INFO] Saving: ${chain.name} (${chain.chainId})\n`); - mkdirSync(`./dist/${chain.chainId}`, { recursive: true }); - writeFileSync(`./dist/${chain.chainId}/tokens.json`, JSON.stringify(funibleTokenList)); - writeFileSync(`./dist/${chain.chainId}/non-fungible-tokens.json`, JSON.stringify(nonFungibleTokenList)); + mkdirSync(`./dist/latest/${chain.chainId}`, { recursive: true }); + writeFileSync(`./dist/latest/${chain.chainId}/tokens.json`, JSON.stringify(funibleTokenList)); + writeFileSync(`./dist/latest/${chain.chainId}/non-fungible-tokens.json`, JSON.stringify(nonFungibleTokenList)); } catch (error) { console.error(`[ERROR] Fetching: ${chain.name} (${chain.chainId})`); console.error(error);