Skip to content

Commit

Permalink
chore: Download latest bundle analysis artifact from base branch
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Dec 11, 2023
1 parent f162175 commit bf119b6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/nextjs-bundle-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ jobs:
path: .next/analyze/__bundle_analysis.json

- name: Download base branch bundle stats
uses: dawidd6/action-download-artifact@v2
if: success() && github.event.number
with:
workflow: nextjs_bundle_analysis.yml
branch: ${{ github.event.pull_request.base.ref }}
path: .next/analyze/base
run: bash ./scripts/github/download_bundle_analyser_artifact.sh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}


- name: Compare with base branch bundle
if: success() && github.event.number
Expand Down
29 changes: 29 additions & 0 deletions scripts/github/download_bundle_analyser_artifact.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
set -xe
ORG="safe-global"
REPO="safe-wallet-web"
WORKFLOW="nextjs-bundle-analysis.yml"
ARTIFACT_NAME="bundle"
DESTINATION=".next/analyze/base"
BASE_BRANCH="dev"

ARTIFACTS_URL=$(
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${ORG}/${REPO}/actions/workflows/${WORKFLOW}/runs?event=push&branch=${BASE_BRANCH}&status=success&per_page=1" \
--jq ".workflow_runs[0].artifacts_url"
)

DOWNLOAD_URL=$(
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"${ARTIFACTS_URL}" \
--jq '.artifacts[] | select(.name == "'"${ARTIFACT_NAME}"'") | .archive_download_url'
)

set +x
curl -H "Accept: application/vnd.github+json" -H "Authorization: token $GH_TOKEN" -L -o "${DESTINATION}.zip" "$DOWNLOAD_URL"
set -x
unzip "${DESTINATION}.zip" -d "${DESTINATION}" && mkdir -p "${DESTINATION}/bundle" && mv "${DESTINATION}/__bundle_analysis.json" "${DESTINATION}/bundle/"
rm "${DESTINATION}.zip"
3 changes: 2 additions & 1 deletion src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Typography } from '@mui/material'
import { useEffect, useState } from 'react'
import type { NextPage } from 'next'
import { useRouter } from 'next/router'
Expand Down Expand Up @@ -45,7 +46,7 @@ const Custom404: NextPage = () => {
}
}, [router])

return <main>{!isRedirecting && <h1>404 - Page not found</h1>}</main>
return <main>{!isRedirecting && <Typography variant="h1">404 - Page not found</Typography>}</main>
}

export default Custom404

0 comments on commit bf119b6

Please sign in to comment.