From 20b96580badb74c22e1425be40313d24a6289965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Wed, 18 Dec 2024 21:45:21 +0100 Subject: [PATCH] fix(action): workaround for private repos Download repo tarball instead of trying to use git switch to the proper branch. --- action.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 2653b1f..9e98fc5 100644 --- a/action.yml +++ b/action.yml @@ -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