|
37 | 37 | if [ -n "$workspace_dir" ] && [ -d "$workspace_dir" ]; then |
38 | 38 | echo "Checking for git repository in: $workspace_dir" |
39 | 39 | cd "$workspace_dir" |
| 40 | + |
| 41 | + # Handle potential git ownership/permissions issues in Docker |
| 42 | + if [ -d ".git" ]; then |
| 43 | + echo "Found .git directory, attempting to configure git for container access" |
| 44 | + # Tell git it's safe to access this repository |
| 45 | + git config --global --add safe.directory "$workspace_dir" || true |
| 46 | + # Set git config for the container user |
| 47 | + git config --global user.email "[email protected]" || true |
| 48 | + git config --global user.name "GitHub Action" || true |
| 49 | + fi |
| 50 | + |
40 | 51 | if git rev-parse --git-dir > /dev/null 2>&1; then |
41 | 52 | git log -1 --pretty=%B > "$COMMIT_FILE" |
42 | 53 | COMMIT_MESSAGE=$(cat "$COMMIT_FILE") |
43 | 54 | echo "Checking last commit message: $COMMIT_MESSAGE" |
44 | 55 | GIT_DIR_FOUND=true |
45 | 56 | break |
| 57 | + else |
| 58 | + echo "Git command failed, checking permissions..." |
| 59 | + echo "Git directory permissions:" |
| 60 | + ls -la .git/ 2>/dev/null | head -5 || echo "Cannot read .git directory" |
46 | 61 | fi |
47 | 62 | fi |
48 | 63 | done |
@@ -72,7 +87,12 @@ echo "Running git-commit-linter with args: ${ARGS[@]}" |
72 | 87 |
|
73 | 88 | # Function to set GitHub Actions output (using new format) |
74 | 89 | set_output() { |
75 | | - echo "$1=$2" >> $GITHUB_OUTPUT |
| 90 | + if [ -n "$GITHUB_OUTPUT" ] && [ -w "$(dirname "$GITHUB_OUTPUT")" ]; then |
| 91 | + echo "$1=$2" >> "$GITHUB_OUTPUT" |
| 92 | + else |
| 93 | + echo "Warning: Cannot write to GITHUB_OUTPUT: $GITHUB_OUTPUT" |
| 94 | + echo "Output would be: $1=$2" |
| 95 | + fi |
76 | 96 | } |
77 | 97 |
|
78 | 98 | # Set environment variables for the skip flags |
|
0 commit comments