Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 36 additions & 22 deletions .github/workflows/PRValidation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,63 @@ permissions:
contents: write

jobs:
format:
pr-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}


- name: Setup Bun
uses: oven-sh/setup-bun@v2.0.2

- name: Install dependencies
run: bun install

- name: Run formatter
run: bun run format

- name: Commit changes
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref != 'develop' }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply formatting changes
file_pattern: 'src/**'
branch: ${{ github.event.pull_request.head.ref }}

pr-check:
needs: format
- name: Set environment variables
run: |
echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" >> $GITHUB_ENV
echo "SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}" >> $GITHUB_ENV

- name: Run build
run: bun run build

format:
needs: pr-check
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Si esto es un PR, checkoutea la rama del PR; sino usa la ref normal (workflow_dispatch / push)
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}

- name: Setup Bun
uses: oven-sh/setup-bun@v2.0.2

- name: Install dependencies
run: bun install

- name: Set environment variables
- name: Check formatting
id: fmt-check
run: |
echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" >> $GITHUB_ENV
echo "SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}" >> $GITHUB_ENV
# Intentamos hacer un "check" del formateador; si está bien, devolvemos formatted=true
# Si el check falla, devolvemos formatted=false para ejecutar el formatter luego.
if bun run prettier . --check; then
echo "formatted=true" >> $GITHUB_OUTPUT
else
echo "formatted=false" >> $GITHUB_OUTPUT
fi

- name: Run build
run: bun run build
- name: Run formatter (only if needed)
if: ${{ steps.fmt-check.outputs.formatted == 'false' }}
run: bun run format

- name: Commit formatting changes
if: ${{ github.event_name == 'pull_request' && steps.fmt-check.outputs.formatted == 'false' && github.event.pull_request.head.ref != 'develop' }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply formatting changes
file_pattern: 'src/**'
branch: ${{ github.event.pull_request.head.ref }}