File tree Expand file tree Collapse file tree 3 files changed +51
-96
lines changed
Expand file tree Collapse file tree 3 files changed +51
-96
lines changed Original file line number Diff line number Diff line change 2121 uses : actions/checkout@v4
2222
2323 - name : Detect unnecessary execution permissions
24- run : php utils/check_permission_x.php
24+ run : utils/check-file-permissions
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -eu
3+
4+ INCLUDE_DIRS=(
5+ ' .github/'
6+ ' admin/'
7+ ' app/'
8+ ' changelogs/'
9+ ' contributing/'
10+ ' public/'
11+ ' system/'
12+ ' tests/'
13+ ' user_guide_src/'
14+ ' utils/'
15+ ' writable/'
16+ )
17+ EXCLUDE_FILES=(
18+ ' :!.github/scripts/deploy-userguide'
19+ ' :!admin/release-userguide'
20+ ' :!admin/release-deploy'
21+ ' :!admin/apibot'
22+ ' :!admin/alldocs'
23+ ' :!admin/release'
24+ ' :!admin/docbot'
25+ ' :!admin/release-notes.bb'
26+ ' :!admin/release-revert'
27+ ' :!admin/starter/builds'
28+ ' :!admin/userguide/.github/scripts/deploy.sh'
29+ ' :!user_guide_src/add-edit-this-page'
30+ )
31+ FILES_WITH_WRONG_PERMISSIONS=$(
32+ git ls-files --stage " ${INCLUDE_DIRS[@]} " " ${EXCLUDE_FILES[@]} " \
33+ | grep --extended-regexp " ^100755 " \
34+ | sort -fh
35+ )
36+
37+ if [[ -n " $FILES_WITH_WRONG_PERMISSIONS " ]]; then
38+ printf ' \033[41m FAIL \033[0m Files with unnecessary execution permissions were detected:\n'
39+ [[ -z " ${GITHUB_ACTIONS+x} " ]] || echo ' ::group::Non-executable files'
40+ echo " $FILES_WITH_WRONG_PERMISSIONS " | awk ' {print " - " $4}'
41+ echo ' '
42+ echo " $FILES_WITH_WRONG_PERMISSIONS " | awk ' {print $4}' | xargs -n1 printf ' Please run "\033[32msudo chmod\033[0m -x %s".\n'
43+ [[ -z " ${GITHUB_ACTIONS+x} " ]] || echo ' ::endgroup::'
44+ fi
45+
46+ if [[ -n " $FILES_WITH_WRONG_PERMISSIONS " ]]; then
47+ exit 1
48+ fi
49+
50+ printf ' \033[42m OK \033[0m No files with unnecessary execution permissions were detected.\n'
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments