diff --git a/action.yml b/action.yml index a971657..d8e5e56 100644 --- a/action.yml +++ b/action.yml @@ -36,6 +36,7 @@ runs: id: check-changed-files env: ACTION_REF: ${{ github.action_ref }} + ACTION_SHA: ${{ github.action_sha }} run: | # Check if curl is installed, if not install it if ! command -v curl &> /dev/null; then @@ -58,7 +59,22 @@ runs: if [ -n "${{ inputs.github_user_token }}" ]; then AUTH_PREFIX="oauth2:${{ inputs.github_user_token }}@" fi - curl -s -L -o /tmp/check_changed_files.py https://${AUTH_PREFIX}raw.githubusercontent.com/ZPascal/check-changed-files-action/refs/heads/$ACTION_REF/src/check_changed_files.py + + # Determine the correct ref (commit SHA, tag, branch, or default to main) + if [ -n "$ACTION_SHA" ]; then + # Use commit SHA as primary reference (always valid) + REF_PATH="$ACTION_SHA" + elif [ -n "$ACTION_REF" ]; then + # Extract the actual ref name from refs/tags/* or refs/heads/* + # ACTION_REF format: refs/tags/v1.0.0 or refs/heads/main + REF_PATH="${ACTION_REF#refs/tags/}" + REF_PATH="${REF_PATH#refs/heads/}" + else + # Fallback to main branch + REF_PATH="main" + fi + + curl -s -L -o /tmp/check_changed_files.py "https://${AUTH_PREFIX}raw.githubusercontent.com/ZPascal/check-changed-files-action/$REF_PATH/src/check_changed_files.py" optional_flags="" if [ -n "${{ inputs.git_location }}" ]; then