Check TS Errors and Open PR #493
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 TS Errors and Open PR | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs daily at midnight UTC | |
workflow_dispatch: #Manual trigger | |
jobs: | |
check-ts-errors: | |
runs-on: ubuntu-latest | |
steps: | |
- name: git config | |
run: | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions" | |
git config --global url.https://${{ secrets.TOKEN }}@github.com/.insteadOf https://github.com/ | |
- name: Clone Repo's | |
run: | | |
git clone https://github.com/mattpocock/ts-error-translator.git && git clone https://github.com/dmmulroy/ts-error-translator.nvim.git | |
env: | |
GH_TOKEN: ${{ secrets.TOKEN }} | |
- name: Check for directory differences | |
run: | | |
dir1="ts-error-translator/packages/engine/errors/" | |
dir2="ts-error-translator.nvim/error_templates" | |
# Use diff to compare the directories and store the differences in a variable | |
differences=$(diff -rq $dir1 $dir2 || true) | |
echo $differences | |
differences=$(diff -rq "$dir1" "$dir2" || true) | |
echo "$differences" | |
if [ -n "$differences" ]; then | |
# Delete everything in dir2 | |
rm -rf "$dir2" | |
# Copy everything from dir1 to dir2 | |
cp -r "$dir1" "$dir2" | |
# Commit the changes and push to a new branch | |
cd ts-error-translator.nvim/ | |
branch_name="auto-pr-$(date +%d-%b-%Y)" | |
git pull origin | |
git checkout -b "$branch_name" | |
git add . | |
git commit -m "Auto commit for directory differences" | |
git push -f origin "$branch_name" | |
gh pr create --fill -B "main" -H $branch_name --title "Sync_error_templates" --body "Syncing error_templates from upstream ts-error-translator" -r dmmulroy | |
fi | |
env: | |
GH_TOKEN: ${{ github.token }} | |
permissions: | |
pull-requests: write |