codeflash-internal/.github/workflows/fix-formatting.yml
Kevin Turcios eeecdc11d7
Bump stale GitHub Actions versions (#2618)
## Summary

Bumps all stale GitHub Actions to their latest stable versions across 7
workflow files.

### Changes

| Workflow | Action | Old | New |
|---|---|---|---|
| `ci.yaml` | `astral-sh/setup-uv` | `@v8.0.0` / `@v7` (inline jobs
only) | `@v8.1.0` |
| `claude.yml` | `astral-sh/setup-uv` | `@v6` | `@v8.1.0` |
| `codeflash-aiservice.yaml` | `astral-sh/setup-uv` | `@v7` | `@v8.1.0`
|
| `codeflash-js.yaml` | `astral-sh/setup-uv` | `@v7` | `@v8.1.0` |
| `deploy_aiservice_to_azure.yml` | `astral-sh/setup-uv` | `@v7` |
`@v8.1.0` |
| `fix-formatting.yml` | `astral-sh/setup-uv` | `@v5` | `@v8.1.0` |
| `fix-formatting.yml` | `j178/prek-action` | `@v1` | `@v2` |
| `publish-to-pypi.yml` | `pypa/gh-action-pypi-publish` | `@master` |
`@release/v1` |

### Notes

- Shared workflow refs (`codeflash-ai/github-workflows/...@main`) in
`ci.yaml` are **not** changed -- those follow `@main` and will pick up
updates from the shared workflows repo.
- `publish-to-pypi.yml` is currently disabled (`if: false`) but the ref
is fixed anyway to avoid issues when re-enabled.

## Test plan

- [ ] CI passes on this PR (the workflow files themselves are the
change, so CI validates they parse correctly)
- [ ] Verify `ci.yaml` shared workflow `uses:` lines still reference
`@main`
2026-04-23 05:49:17 -05:00

59 lines
2 KiB
YAML

name: Fix Formatting
on:
issue_comment:
types: [created]
jobs:
fix-formatting:
if: github.event.issue.pull_request && contains(github.event.comment.body, '/fix-formatting')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Get PR info
id: pr-info
env:
GH_TOKEN: ${{ github.token }}
run: |
PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }})
echo "head_ref=$(echo $PR_DATA | jq -r '.head.ref')" >> $GITHUB_OUTPUT
echo "base_ref=$(echo $PR_DATA | jq -r '.base.ref')" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ steps.pr-info.outputs.head_ref }}
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
- name: Run prek
id: prek
uses: j178/prek-action@v2
continue-on-error: true
with:
extra-args: --from-ref origin/${{ steps.pr-info.outputs.base_ref }}
- name: Push fixes if any
env:
GH_TOKEN: ${{ github.token }}
PREK_OUTCOME: ${{ steps.prek.outcome }}
run: |
git fetch origin ${{ steps.pr-info.outputs.base_ref }}
if [ -n "$(git status --porcelain)" ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "fix: auto-format with prek"
git push
gh pr comment ${{ github.event.issue.number }} --body "✅ Fixed formatting with prek and pushed."
elif [ "$PREK_OUTCOME" = "failure" ]; then
gh pr comment ${{ github.event.issue.number }} --body "❌ Prek found issues but couldn't auto-fix them. Please check the logs."
exit 1
else
gh pr comment ${{ github.event.issue.number }} --body "✅ No formatting issues found."
fi