[DAPS-1847] - refactor: python package to be compatible with proto3 e… #475
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: Shell Format Check | |
| on: | |
| push: | |
| paths: | |
| - "**.sh" | |
| pull_request: | |
| paths: | |
| - "**.sh" | |
| jobs: | |
| shfmt: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| ref: ${{ github.head_ref || github.ref }} | |
| - name: Install shfmt | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y shfmt | |
| - name: Format shell scripts | |
| run: | | |
| echo "Auto-formatting shell scripts..." | |
| # Run in check mode: if reformatting would be needed, it will fail | |
| # Use indentation space of 2 spaces | |
| shfmt -i 2 -w . | |
| echo "Formatting complete" | |
| - name: Commit changes | |
| run: | | |
| # Get the original commit author info | |
| AUTHOR_NAME=$(git log -1 --pretty=format:'%an') | |
| AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae') | |
| # Use original author for the formatting commit | |
| git config --local user.email "$AUTHOR_EMAIL" | |
| git config --local user.name "$AUTHOR_NAME" | |
| # Check if there are any changes | |
| if [[ -n $(git status -s) ]]; then | |
| echo "Formatting changes detected, creating commit..." | |
| echo "Committing as: $AUTHOR_NAME <$AUTHOR_EMAIL>" | |
| git add -A | |
| git commit -m "chore: Auto-format shell scripts with shfmt" | |
| # Push changes | |
| git push | |
| echo "Changes committed and pushed" | |
| else | |
| echo "No formatting changes needed" | |
| fi |