diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 391d1710..f0d6a849 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -25,15 +25,29 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x] steps: - name: Checkout uses: actions/checkout@v3 - - name: Setup Pages - uses: actions/configure-pages@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - name: Install Dependencies + run: cd client && npm install + - name: Build + env: + NODE_OPTIONS: "--max_old_space_size=4096" + CI: true + run: cd client && npm run build - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: path: './client/dist/' + - name: Setup Pages + uses: actions/configure-pages@v3 - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v2 diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index f13903e7..a0db8a3b 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -108,12 +108,7 @@ jobs: env: NODE_OPTIONS: "--max_old_space_size=4096" run: cd client && npm run build - - name: Upload Build artifacts - uses: actions/upload-artifact@v3.1.2 - with: - name: Build artifacts - path: ./client/dist/ - + test: needs: [build-and-install-deps] runs-on: ubuntu-latest @@ -134,5 +129,5 @@ jobs: with: path: ./client/node_modules key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} - - name: Build + - name: Test With Coverage run: cd client && npm run test:cov diff --git a/client/scripts/deploy.ts b/client/scripts/deploy.ts index 7bb71637..8ef923b1 100644 --- a/client/scripts/deploy.ts +++ b/client/scripts/deploy.ts @@ -4,6 +4,11 @@ import Bundlr from 'bundlr-custom'; import fs from 'fs'; const main = async () => { + + if (!fs.existsSync('./wallet.json')) { + console.log('No wallet file found, please add a wallet.json file to the root of the project'); + return; + } const wallet = './wallet.json'; const jwk = JSON.parse(fs.readFileSync(wallet).toString()); @@ -25,10 +30,28 @@ const main = async () => { // Print your wallet address console.log(`wallet address = ${bundlr.address}`); const dist = './dist/'; + + try { + if (fs.existsSync('dist-id.txt')) { + fs.rmSync('dist-id.txt'); + } + if (fs.existsSync('dist-manifest.csv')) { + fs.rmSync('dist-manifest.csv'); + } + if (fs.existsSync('dist-manifest.json')) { + fs.rmSync('dist-manifest.json'); + } + } catch (error) { + // files not found skip + console.log('No previous deploy files found, skipping'); + } + console.log('uploading'); + const response = await bundlr.uploadFolder(dist, { indexFile: 'index.html', // optional index file (file the user will load when accessing the manifest) - batchSize: 50, // number of items to upload at once - keepDeleted: false // whether to keep now deleted items from previous uploads + batchSize: 50, // number of items to upload at once, + keepDeleted: false, // keep deleted files in the manifest + logFunction: async (log: string) => console.log(log), // optional function to handle logs }); // returns the manifest ID console.log(`SPA Uploaded https://arweave.net/${response?.id}`);