Time: 1252 ms (55.08%) | Memory: 0B (100.00%) - LeetSync #20
This file contains hidden or 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: Organize Solutions by Language Folder | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| organize: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout código | |
| uses: actions/checkout@v4 | |
| - name: Organize folders into language directories | |
| run: | | |
| # 1. Cria os diretórios de nível superior | |
| mkdir -p SQL Python CSharp | |
| # 2. Percorre cada pasta de problema | |
| for problem_dir in */; do | |
| # Ignora pastas de configuração e as que já foram criadas | |
| if [[ "$problem_dir" == ".git/" || "$problem_dir" == ".github/" || "$problem_dir" == "SQL/" || "$problem_dir" == "Python/" || "$problem_dir" == "CSharp/" ]]; then | |
| continue | |
| fi | |
| # Pega apenas o nome base do diretório, sem a barra "/" no final | |
| base_name=$(basename "$problem_dir") | |
| echo "Processing: $base_name" | |
| # 3. Verifica cada tipo de arquivo e move para a estrutura correta | |
| # Usa o $base_name para criar o caminho de destino correto | |
| if ls "${problem_dir}"*.sql 1> /dev/null 2>&1; then | |
| echo " - Found SQL file." | |
| dest="SQL/${base_name}" | |
| mkdir -p "$dest" | |
| mv "${problem_dir}"* "$dest/" | |
| fi | |
| if ls "${problem_dir}"*.py 1> /dev/null 2>&1; then | |
| echo " - Found Python file." | |
| dest="Python/${base_name}" | |
| mkdir -p "$dest" | |
| mv "${problem_dir}"* "$dest/" | |
| fi | |
| if ls "${problem_dir}"*.cs 1> /dev/null 2>&1; then | |
| echo " - Found CSharp file." | |
| dest="CSharp/${base_name}" | |
| mkdir -p "$dest" | |
| mv "${problem_dir}"* "$dest/" | |
| fi | |
| done | |
| - name: Commit and Push changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add . | |
| if ! git diff-index --quiet HEAD; then | |
| git commit -m "chore: organize solutions into language-specific directories" | |
| git push | |
| else | |
| echo "No changes to commit." | |
| fi |