Skip to content

Commit

Permalink
Merge branch 'develop' for v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mrrobot47 committed Jan 27, 2020
2 parents 3fc22ec + 3b6a0da commit 388e00d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN set -eux; \
cowsay \
git \
gosu \
jq \
php7.2-cli \
php7.2-curl \
php-xml \
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ on: pull_request

jobs:
phpcs:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: rtCamp/action-phpcs-code-review@master
- uses: docker://rtcamp/action-phpcs-code-review:v2.0.0
env:
GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
with:
Expand All @@ -43,6 +41,12 @@ Now, next time you create a pull request or commit on an existing pull request,

By default, pull request will be reviwed using WordPress coding and documentation standards. You can change the default by passing different [PHPCS Coding Standard(s)](#phpcs-coding-standards) in line `args = ["WordPress-Core,WordPress-Docs"]`.

4. In case you want to skip PHPCS scanning in any pull request, add `[do-not-scan]` in the PR description. You can add it anywhere in the description and it will skip the action run for that pull request.

---

Side note: in the usage example, we have used `docker://rtcamp/action-phpcs-code-review:v2.0.0`, which is the docker image set up with automated builds on this repo. It will always have the latest code of this repo. Instead of using docker image you can also use the repo url in it: `rtCamp/action-phpcs-code-review@v2.0.0`. The disadvantage using the repo url is that GitHub actions now builds the docker image from url every time action is executed (does not cache the docker image after first run _by default_ as it used to do in beta. You need to cache them seprately). That consumes a fairly good amount of time in action run. Leading to a longer running job as well as more billing (if used in private repo).

## GitHub Token Creation

You can create [GitHub Token from here](https://github.com/settings/tokens).
Expand Down
14 changes: 6 additions & 8 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

cd $GITHUB_WORKSPACE

# Checkout to the latest commit of the PR. As the vip-go-ci runner needs the commit id from PR.
# If ref matches *refs/pull*, then an additional PR commit has been added by GH actions, and needs to be skipped.
if [[ "$GITHUB_REF" == *"refs/pull"* ]]; then
COMMIT_ID=$(git log -n 1 --skip 1 --pretty=format:"%H")
git checkout -b pr "$COMMIT_ID"
else
COMMIT_ID="$GITHUB_SHA"
fi
COMMIT_ID=$(cat $GITHUB_EVENT_PATH | jq -r '.pull_request.head.sha')

echo "COMMIT ID: $COMMIT_ID"

PR_BODY=$(cat "$GITHUB_EVENT_PATH" | jq -r .pull_request.body)
if [[ "$PR_BODY" == *"[do-not-scan]"* ]]; then
echo "[do-not-scan] found in PR description. Skipping PHPCS scan."
exit 0
fi

stars=$(printf "%-30s" "*")

Expand Down

0 comments on commit 388e00d

Please sign in to comment.