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 2e7e134
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/nextjs-bundle-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@ 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_artifact.sh


- name: Compare with base branch bundle
if: success() && github.event.number
Expand Down
29 changes: 29 additions & 0 deletions scripts/github/download_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 ${{ secrets.GITHUB_TOKEN }}" -L -o "${DESTINATION}.zip" "$DOWNLOAD_URL"
set -x
unzip "${DESTINATION}.zip" -d "${DESTINATION}"
rm "${DESTINATION}.zip"

0 comments on commit 2e7e134

Please sign in to comment.