Skip to content

Commit

Permalink
Rewrite action version check
Browse files Browse the repository at this point in the history
The crucial missing component was cding into the preview repository
after bare cloning it. Without that, this script has been checking the
version of the user's project repository this entire time.
  • Loading branch information
rossjrw committed May 18, 2023
1 parent 70d0e7a commit aa0f798
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ runs:
shell: bash

- name: Determine action version
run: >-
$GITHUB_ACTION_PATH/lib/find-current-git-tag.sh
-p $actionrepo -f $actionref
run: |
action_version=$("${{ github.action_path }}/lib/find-current-git-tag.sh" -p $actionrepo -f $actionref)
echo "action_version=$action_version" >> "$GITHUB_ENV"
shell: bash

- name: Determine auto action
Expand Down
20 changes: 10 additions & 10 deletions lib/find-current-git-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ if [ -z "$github_repository" ] || [ -z "$git_ref" ]; then
helpFunction
fi

echo >&2 "Determining preview action version"
echo >&2 "Determining Git tag for $github_repository/$git_ref"

echo >&2 "Cloning repository $github_repository at ref $git_ref"
if git clone --bare --single-branch --branch "$git_ref" "https://github.com/$github_repository" bare_pr_preview; then
echo >&2 "Finding most specific tag matching tag $git_ref"
action_version=$(git describe --tags --match "v*.*.*" || git describe --tags || git rev-parse HEAD)
echo >&2 "Found $action_version"
echo "action_version=$action_version" >>"$GITHUB_ENV"
else
echo >&2 "Clone failed; using truncated ref as action version"
echo "action_version=${git_ref:0:9}" >>"$GITHUB_ENV"
fi
git clone --bare --single-branch --branch "$git_ref" "https://github.com/$github_repository" bare_pr_preview

cd bare_pr_preview || exit 1

action_version=$(git describe --tags --match "v*.*.*" || git describe --tags || git rev-parse HEAD)

echo "$action_version"
exit 0

0 comments on commit aa0f798

Please sign in to comment.