Skip to content

Commit

Permalink
Add: [Action] allow this repository also to be used as GitHub Action (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueBrain authored May 20, 2021
1 parent 1953c53 commit 7e826a9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: 'OpenTTD Commit Checker'
author: 'OpenTTD Dev Team'
description: 'Checker for commits done to OpenTTD projects'
inputs: {}
runs:
using: 'composite'
steps:
- run: ${{ github.action_path }}/action/entrypoint.sh ${{ github.action_path }}
shell: bash
branding:
icon: 'code'
color: 'blue'
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions action/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
set -ex

HOOKS_DIR=$1

# Install matchers.
echo "::add-matcher::${HOOKS_DIR}/action/check-diff-matcher.json"
echo "::add-matcher::${HOOKS_DIR}/action/check-message-matcher.json"

# Show what commits we are evaluating.
git log --oneline HEAD^..HEAD^2

# Run the checker.
HOOKS_DIR=${HOOKS_DIR}/hooks GIT_DIR=.git ${HOOKS_DIR}/hooks/check-commits.sh HEAD^..HEAD^2

# Remove matchers.
echo "::remove-matcher owner=check-diff::"
echo "::remove-matcher owner=check-message::"
10 changes: 0 additions & 10 deletions hooks/check-commits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ finish() {
}
trap finish EXIT

if [ ${GITHUB_ACTIONS} ]; then
echo "::add-matcher::${HOOKS_DIR}/check-diff-matcher.json"
echo "::add-matcher::${HOOKS_DIR}/check-message-matcher.json"
fi

hashes=$(git rev-list "$1")
for h in ${hashes}
do
Expand All @@ -39,9 +34,4 @@ do
${HOOKS_DIR}/check-message.py ${tmp_msg_file} server || failure=1
done

if [ ${GITHUB_ACTIONS} ]; then
echo "::remove-matcher owner=check-diff::"
echo "::remove-matcher owner=check-message::"
fi

return ${failure}

0 comments on commit 7e826a9

Please sign in to comment.