diff --git a/entrypoint.sh b/entrypoint.sh index 878bd3e..4910db4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,12 +37,27 @@ else if [ -n "$workspace_dir" ] && [ -d "$workspace_dir" ]; then echo "Checking for git repository in: $workspace_dir" cd "$workspace_dir" + + # Handle potential git ownership/permissions issues in Docker + if [ -d ".git" ]; then + echo "Found .git directory, attempting to configure git for container access" + # Tell git it's safe to access this repository + git config --global --add safe.directory "$workspace_dir" || true + # Set git config for the container user + git config --global user.email "action@github.com" || true + git config --global user.name "GitHub Action" || true + fi + if git rev-parse --git-dir > /dev/null 2>&1; then git log -1 --pretty=%B > "$COMMIT_FILE" COMMIT_MESSAGE=$(cat "$COMMIT_FILE") echo "Checking last commit message: $COMMIT_MESSAGE" GIT_DIR_FOUND=true break + else + echo "Git command failed, checking permissions..." + echo "Git directory permissions:" + ls -la .git/ 2>/dev/null | head -5 || echo "Cannot read .git directory" fi fi done @@ -72,7 +87,12 @@ echo "Running git-commit-linter with args: ${ARGS[@]}" # Function to set GitHub Actions output (using new format) set_output() { - echo "$1=$2" >> $GITHUB_OUTPUT + if [ -n "$GITHUB_OUTPUT" ] && [ -w "$(dirname "$GITHUB_OUTPUT")" ]; then + echo "$1=$2" >> "$GITHUB_OUTPUT" + else + echo "Warning: Cannot write to GITHUB_OUTPUT: $GITHUB_OUTPUT" + echo "Output would be: $1=$2" + fi } # Set environment variables for the skip flags