forked from rtCamp/action-phpcs-code-review
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
50 lines (37 loc) · 1.7 KB
/
main.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
stars=$(printf "%-30s" "*")
export RTBOT_WORKSPACE="/home/rtbot/github-workspace"
hosts_file="$GITHUB_WORKSPACE/.github/hosts.yml"
rsync -a "$GITHUB_WORKSPACE/" "$RTBOT_WORKSPACE"
rsync -a /root/vip-go-ci-tools/ /home/rtbot/vip-go-ci-tools
chown -R rtbot:rtbot /home/rtbot/
GITHUB_REPO_NAME=${GITHUB_REPOSITORY##*/}
GITHUB_REPO_OWNER=${GITHUB_REPOSITORY%%/*}
if [[ -n "$VAULT_GITHUB_TOKEN" ]] || [[ -n "$VAULT_TOKEN" ]]; then
export GH_BOT_TOKEN=$(vault read -field=token secret/rtBot-token)
fi
phpcs_standard=''
defaultFiles=(
'.phpcs.xml'
'phpcs.xml'
'.phpcs.xml.dist'
'phpcs.xml.dist'
)
phpcsfilefound=1
for phpcsfile in "${defaultFiles[@]}"; do
if [[ -f "$RTBOT_WORKSPACE/$phpcsfile" ]]; then
phpcs_standard="--phpcs-standard=$RTBOT_WORKSPACE/$phpcsfile"
phpcsfilefound=0
fi
done
if [[ $phpcsfilefound -ne 0 ]]; then
if [[ -n "$1" ]]; then
phpcs_standard="--phpcs-standard=$1"
else
phpcs_standard="--phpcs-standard=WordPress"
fi
fi
/usr/games/cowsay "Running with the flag $phpcs_standard"
echo "Running the following command"
echo "/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=$GITHUB_REPO_OWNER --repo-name=$GITHUB_REPO_NAME --commit=$GITHUB_SHA --token=\$GH_BOT_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true $phpcs_standard --lint=true"
gosu rtbot bash -c "/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=$GITHUB_REPO_OWNER --repo-name=$GITHUB_REPO_NAME --commit=$GITHUB_SHA --token=$GH_BOT_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true $phpcs_standard --lint=true"