Skip to content

Commit

Permalink
Merge pull request #3 from tj-actions/feature/update-to-use-list
Browse files Browse the repository at this point in the history
  • Loading branch information
Tonye Jack committed Jul 31, 2020
2 parents c737ea7 + 7bb0d4f commit 9aaebbb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
name: Test verify-changed-files
steps:
- name: Checkout
uses: actions/checkout@v2
- name: shellcheck
uses: reviewdog/action-shellcheck@v1
5 changes: 2 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ inputs:
required: true
default: ${{ github.token }}
files:
description: Comma separated list of files to check for changes.
required: false
default: ''
description: List of files to check for changes.
required: true
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
14 changes: 9 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

set -e

GITHUB_TOKEN=$1
FILES=$2

echo "Formatting filenames..."
EXPECTED_FILES="$(printf $(echo ${FILES} | sed 's| ||g' | sed 's/,/|/g'))"
CHANGED_FILES=()

echo "Checking changes for \"${EXPECTED_FILES}\"... "
CHANGED_FILES=$(git diff --diff-filter=ACM --name-only | grep -E "(${EXPECTED_FILES})" || true)
for path in ${FILES}
do
echo "Checking for file changes: \"${path}\"..."
MODIFIED_FILE=$(git diff --diff-filter=ACM --name-only | grep -E "(${path})" || true)
if [[ -n ${MODIFIED_FILE} ]]; then
CHANGED_FILES+=("${path}")
fi
done

if [[ -z ${CHANGED_FILES} ]]; then
echo "::set-output name=files_changed::false"
Expand Down

0 comments on commit 9aaebbb

Please sign in to comment.