-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathset-laravel-permissions-ci.sh
More file actions
28 lines (19 loc) · 1.1 KB
/
set-laravel-permissions-ci.sh
File metadata and controls
28 lines (19 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# Usage: ./set-laravel-permissions-ci.sh /path/to/laravel
# In GitHub Actions, just point to the Laravel app root (default: current directory)
set -ex
LARAVEL_ROOT="${1:-.}"
echo "🔧 Setting Laravel file permissions in CI environment at: $LARAVEL_ROOT"
# General project-wide permissions
# Only touch files/dirs owned by the current user to avoid "Operation not permitted"
# errors on runtime files created by the web server process (e.g. session files).
CURRENT_USER="$(whoami)"
echo "📁 Setting directory permissions to 755..."
find "$LARAVEL_ROOT" -type d -user "$CURRENT_USER" -exec chmod 755 {} +
echo "📄 Setting file permissions to 644..."
find "$LARAVEL_ROOT" -type f -user "$CURRENT_USER" -exec chmod 644 {} +
# Writable directories: storage & bootstrap/cache
echo "📝 Making storage/ and bootstrap/cache/ writable..."
find "$LARAVEL_ROOT/storage" "$LARAVEL_ROOT/bootstrap/cache" -type d -user "$CURRENT_USER" -exec chmod 775 {} +
find "$LARAVEL_ROOT/storage" "$LARAVEL_ROOT/bootstrap/cache" -type f -user "$CURRENT_USER" -exec chmod 664 {} +
echo "✅ CI permissions set successfully."