Merge pull request #1 from ChangePlusPlusVandy/setup/dev-setup #3
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: Prettier Auto-Format | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| prettier-frontend: | |
| name: Prettier Frontend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| working-directory: ./frontend | |
| run: npm install | |
| - name: Run Prettier and Format Code | |
| working-directory: ./frontend | |
| run: npm run format | |
| - name: Commit formatting changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add . | |
| git diff --staged --quiet || git commit -m "Auto-format frontend code with Prettier" | |
| - name: Push changes | |
| run: git push | |
| prettier-backend: | |
| name: Prettier Backend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| working-directory: ./backend | |
| run: npm install | |
| - name: Run Prettier and Format Code | |
| working-directory: ./backend | |
| run: npm run format | |
| - name: Commit formatting changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add . | |
| git diff --staged --quiet || git commit -m "Auto-format backend code with Prettier" | |
| - name: Push changes | |
| run: git push |