Update tree_sitter_maker.yml #17
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: Tree-Sitter Python Clone and Modify | |
on: | |
schedule: | |
# This cron job runs at 00:00 every Sunday | |
- cron: '0 0 * * 0' | |
push: | |
paths: | |
- '.github/workflows/tree_sitter_maker.yml' | |
jobs: | |
clone-modify-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Backup important files and directories | |
run: | | |
mkdir -p /tmp/backup/ | |
cp -a .github/workflows/tree_sitter_maker.yml /tmp/backup/ | |
cp -a .git /tmp/backup/ | |
cp -a README.md /tmp/backup/ | |
- name: Clear repository contents | |
run: | | |
rm -rf ./* .[!.]* ..?* | |
- name: Clone tree-sitter-python | |
run: | | |
git clone https://github.com/tree-sitter/tree-sitter-python.git | |
rm -rf tree-sitter-python/.git | |
rm -rf tree-sitter-python/.github | |
rm -f tree-sitter-python/README.md | |
mv tree-sitter-python/* . | |
mv tree-sitter-python/.[!.]* . | |
rm -rf tree-sitter-python | |
- name: Replace to mojo | |
run: | | |
find . -type f -exec sed -i 's/PYTHON/MOJO/g' {} + | |
find . -type f -exec sed -i 's/Python/Mojo/g' {} + | |
find . -type f -exec sed -i 's/python/mojo/g' {} + | |
find . -type f -exec sed -i 's/"py"/"mojo"/g' {} + | |
find . -depth \( -type f -or -type d \) -name '*python*' -exec bash -c 'mv "$0" "${0//python/mojo}"' {} \; | |
- name: Restore backups | |
run: | | |
mkdir -p .github/workflows | |
mv /tmp/backup/tree_sitter_maker.yml .github/workflows/ | |
mv /tmp/backup/.git . | |
mv /tmp/backup/README.md . | |
echo $(find .) | |
- name: Commit changes | |
run: | | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email '' | |
git add -A | |
echo $(git status) | |
if git diff --staged --quiet; then | |
echo "No changes, skipping commit and push." | |
else | |
git commit -m "Update from tree-sitter-python" | |
git push origin master | |
fi |