Test js #91
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Typos in Pull Request | |
on: [pull_request] | |
jobs: | |
check-typos: | |
permissions: write-all | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Get changed files | |
id: changed-files | |
run: | | |
set -e | |
echo "Listing changed files..." | |
git fetch --all | |
current_commit=${{ github.event.pull_request.head.sha || github.sha }} | |
echo "Current commit: $current_commit" | |
changed_files=$(git show --pretty="" --name-only $current_commit || true) | |
echo "Changed files: $changed_files" | |
if [ -z "$changed_files" ]; then | |
echo "CHANGED_FILES=false" >> $GITHUB_ENV | |
else | |
echo "CHANGED_FILES=true" >> $GITHUB_ENV | |
echo "$changed_files" | tr ' ' '\n' > changed_files.txt | |
echo "CHANGED_FILE_LIST=changed_files.txt" >> $GITHUB_ENV | |
fi | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.14.0-alpha.1' | |
- name: Install typos | |
run: | | |
python3 -m pip install --upgrade pip | |
pip install typos | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Install Axios via npm | |
run: npm install axios | |
- name: Check typos in changed files and comment on PR | |
run: | | |
set -e | |
echo "Checking typos in changed files..." | |
# Loop through each changed file | |
while IFS= read -r file; do | |
echo "Checking typos in $file" | |
# Run typos checker and capture output, including errors | |
typos_output=$(typos "$file" --format brief 2>&1) || true | |
# Check if typos output exists | |
if [[ -n "$typos_output" ]]; then | |
echo "Typos found in $file:" | |
echo "$typos_output" | |
TYPO_OUTPUT="$typos_output" \ | |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \ | |
REPO=${{ github.repository }} \ | |
PULL_NUMBER=${{ github.event.pull_request.number }} \ | |
COMMIT_ID=${{ github.event.pull_request.head.sha || github.sha }} \ | |
node rename.js | |
else | |
echo "No typos found in $file." | |
fi | |
done < ${{ env.CHANGED_FILE_LIST }} |