Skip to content

Restructuring validations and workflows #39

Restructuring validations and workflows

Restructuring validations and workflows #39

name: Article Validator
on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11]
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- run: echo "Checkout code"
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- run: echo "Setting up Python"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- run: echo "Installing Dependencies"
# Find all new or modified markdown files in the articles folder
- name: Find new and modified articles
id: find_files
run: |
# Find new or modified markdown files in the 'articles' directory
MODIFIED_FILES=$(git diff --name-only --diff-filter=ACM origin/main HEAD -- "articles/*.md")
if [ -z "$MODIFIED_FILES" ]; then
echo "No new or modified articles found."
echo "::set-output name=modified_files::"
else
echo "New or modified markdown files found:"
echo "$MODIFIED_FILES"
echo "::set-output name=modified_files::$MODIFIED_FILES"
fi
# Run sanity check for modified files
- name: Run sanity check
run: |
if [ -z "${{ steps.find_files.outputs.modified_files }}" ]; then
echo "No articles to validate."
else
chmod +x sanity_check.sh
for file in ${{ steps.find_files.outputs.modified_files }}; do
echo "Validating $file..."
./sanity_check.sh "$file"
done
fi