fix(action): workaround for private repos

Download repo tarball instead of trying to use git switch to the proper
branch.
This commit is contained in:
Jalil David Salamé Messina 2024-12-18 21:45:21 +01:00
parent 1db9349c00
commit 20b96580ba
Signed by: jalil
GPG key ID: F016B9E770737A0B

View file

@ -7,7 +7,8 @@ description: |
You can post this report as a comment to the PR associated with the current
branch and/or export the report as a markdown artifact.
Requires `nix`, `jq`, `curl`, `sed` and `coreutils` to be in path.
Requires `nix`, `jq`, `curl`, `sed`, `gunzip`, `tar` and `coreutils` to be in
the runner's path.
Usage:
@ -98,10 +99,15 @@ runs:
}
if [ "$PRIVATE_REPO" = 'true' ]; then
log "In a private repo, switching to $HEAD_BRANCH to build the old report"
git switch "$HEAD_BRANCH"
log "In a private repo, downloading $HEAD_BRANCH to build the old report"
"$GITHUB_ACTION_PATH/create-report.sh" > old-report.json
mkdir -p old
curl -X 'GET' \
"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/archive/$HEAD_BRANCH.tar.gz" \
-H "Authorization: token $GITHUB_TOKEN" |
tar -zvx --strip-components=1 -C old
(cd old && "$GITHUB_ACTION_PATH/create-report.sh") > old-report.json
log "Reporting on sizes and comparing to sizes in $HEAD_BRANCH"
"$GITHUB_ACTION_PATH/comment_on_pr.sh" report.json old-report.json