mirror of
https://github.com/public-apis/public-apis.git
synced 2025-05-20 04:26:20 +02:00
Create new workflow to run test of push and pull
This commit is contained in:
parent
bc02fa517f
commit
9bb225ef3d
3 changed files with 90 additions and 29 deletions
57
scripts/github_pull_request.sh
Normal file
57
scripts/github_pull_request.sh
Normal file
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# Argument validation
|
||||
if [ $# -ne 3 ]; then
|
||||
echo "Usage: $0 <github-repo> <pull-number> <filename>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Assign variables
|
||||
GITHUB_REPOSITORY="$1"
|
||||
GITHUB_PULL_REQUEST="$2"
|
||||
FILENAME="$3"
|
||||
|
||||
# Move to root of project
|
||||
cd "$GITHUB_WORKSPACE"
|
||||
|
||||
# Determine files
|
||||
FILENAME="$( realpath "${FILENAME}" )"
|
||||
|
||||
# Skip if build number could not be determined
|
||||
if [ -z "$GITHUB_REPOSITORY" -o -z "$GITHUB_PULL_REQUEST" ]; then
|
||||
echo "No pull request and/or repository is provided"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Pull changes on PR
|
||||
echo "running on Pull Request #$GITHUB_PULL_REQUEST"
|
||||
|
||||
# Trick the URL validator python script into not seeing this as a URL
|
||||
DUMMY_SCHEME="https"
|
||||
DIFF_URL="$DUMMY_SCHEME://patch-diff.githubusercontent.com/raw/$GITHUB_REPOSITORY/pull/$GITHUB_PULL_REQUEST.diff"
|
||||
curl -L "$DIFF_URL" -o diff.txt
|
||||
|
||||
# Construct diff
|
||||
echo "------- BEGIN DIFF -------"
|
||||
cat diff.txt
|
||||
echo "-------- END DIFF --------"
|
||||
cat diff.txt | egrep "\+" > additions.txt
|
||||
|
||||
echo "------ BEGIN ADDITIONS -----"
|
||||
cat additions.txt
|
||||
echo "------- END ADDITIONS ------"
|
||||
LINK_FILE=additions.txt
|
||||
|
||||
# Validate links
|
||||
echo "Running link validation on additions..."
|
||||
python scripts/validate/links.py "$LINK_FILE"
|
||||
|
||||
# Vebosity
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "link validation failed on additions!"
|
||||
exit 1
|
||||
else
|
||||
echo "link validation passed on additions!"
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue